Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to configure ENPreferencesStore via .Net configuration #9

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Evernote-SDK-Windows.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.30723.0
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvernoteSDK", "EvernoteSDK\EvernoteSDK.csproj", "{EFB2706A-EE60-4B33-ABD4-695B509F277B}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "EvernoteSDK_COMSetup", "EvernoteSDK_COMSetup\EvernoteSDK_COMSetup.vdproj", "{1AB456C0-75F7-4606-A6C3-258F088D6B07}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvernoteSDK.Tests", "EvernoteSDK.Tests\EvernoteSDK.Tests.csproj", "{86794611-FE20-4267-95E7-4EF76FBB51FC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -21,6 +23,10 @@ Global
{1AB456C0-75F7-4606-A6C3-258F088D6B07}.Debug|Any CPU.Build.0 = Debug
{1AB456C0-75F7-4606-A6C3-258F088D6B07}.Release|Any CPU.ActiveCfg = Release
{1AB456C0-75F7-4606-A6C3-258F088D6B07}.Release|Any CPU.Build.0 = Release
{86794611-FE20-4267-95E7-4EF76FBB51FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{86794611-FE20-4267-95E7-4EF76FBB51FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{86794611-FE20-4267-95E7-4EF76FBB51FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{86794611-FE20-4267-95E7-4EF76FBB51FC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 8 additions & 0 deletions src/EvernoteSDK.Tests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!-- Uncomment below section to test memory based preference store. The section tag name must be <EvernoteSDK>-->
<!--<configSections>
<section name="EvernoteSDK" type="EvernoteSDK.Configuration.ENSDKConfiguration, EvernoteSDK"/>
</configSections>
<EvernoteSDK preferencesStoreType="EvernoteSDK.Tests.TestMemoryBasedENPreferenceStore, EvernoteSDK.Tests"></EvernoteSDK>-->
</configuration>
30 changes: 30 additions & 0 deletions src/EvernoteSDK.Tests/ENSession_DeleteNote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EvernoteSDK.Tests
{
[TestClass]
public class ENSession_DeleteNote
{
[TestInitialize]
public void Initialize()
{
TestUtils.AuthenticateToEverNote();
}
[TestMethod]
public void WhenNoteContainsHtml_ShoudBeAbleToDelete()
{
// Create a new note (in the user's default notebook) with some HTML content.
ENNote myFancyNote = new ENNote();
myFancyNote.Title = "My fancy note to delete";
myFancyNote.Content = ENNoteContent.NoteContentWithSanitizedHTML("<p>Hello, world - <i>this</i> is a <b>fancy</b> note - and here is a table:</p><br /> <br/><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\"><tr><td>Red</td><td>Green</td></tr><tr><td>Blue</td><td>Yellow</td></tr></table>");
ENNoteRef myFancyNoteRef = ENSession.SharedSession.UploadNote(myFancyNote, null);

// Delete the HTML content note we just created.
ENSession.SharedSession.DeleteNote(myFancyNoteRef);
}
}
}
85 changes: 85 additions & 0 deletions src/EvernoteSDK.Tests/ENSession_DownloadNotes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EvernoteSDK.Tests
{
/// <summary>
/// Summary description for ENSession_DownloadNotes
/// </summary>
[TestClass]
public class ENSession_DownloadNotes
{
public ENSession_DownloadNotes()
{
//
// TODO: Add constructor logic here
//
}

private TestContext testContextInstance;

/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}

#region Additional test attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
TestUtils.AuthenticateToEverNote();
}
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion

[TestMethod]
public void WhenDownloadForAlreadyUploadedNote_ShouldDownloadCorrectNote()
{
string textToFind = Guid.NewGuid().ToString();
ENNote myPlainNote = new ENNote();
myPlainNote.Title = textToFind;
myPlainNote.Content = ENNoteContent.NoteContentWithString(textToFind);
ENSession.SharedSession.UploadNote(myPlainNote, null);

List<ENSessionFindNotesResult> myResultsList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch(textToFind), null, ENSession.SearchScope.All, ENSession.SortOrder.RecentlyUpdated, 500);
bool contentDownloaded = false;
if (myResultsList.Count > 0)
{
// Given a NoteRef instance, download that note.
ENNote myDownloadedNote = ENSession.SharedSession.DownloadNote(myResultsList[0].NoteRef);
contentDownloaded= string.Equals(myDownloadedNote.TextContent, textToFind);
}
Assert.IsTrue(contentDownloaded, "Note able to download required note");
}
}
}
88 changes: 88 additions & 0 deletions src/EvernoteSDK.Tests/ENSession_FindNotes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EvernoteSDK.Tests
{
/// <summary>
/// Summary description for ENSession_FindNotes
/// </summary>
[TestClass]
public class ENSession_FindNotes
{
public ENSession_FindNotes()
{
//
// TODO: Add constructor logic here
//
}

private TestContext testContextInstance;

/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}

#region Additional test attributes
//
// You can use the following additional attributes as you write your tests:

//Use ClassInitialize to run code before running the first test in the class
[ClassInitialize()]
public static void MyClassInitialize(TestContext testContext)
{
TestUtils.AuthenticateToEverNote();
}
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion

[TestMethod]
public void WhenSearchForAlreadyUploadedNote_ShouldSucceed()
{
string textToFind = Guid.NewGuid().ToString();
ENNote myPlainNote = new ENNote();
myPlainNote.Title = textToFind;
myPlainNote.Content = ENNoteContent.NoteContentWithString(textToFind + "My plain text note");
ENSession.SharedSession.UploadNote(myPlainNote, null);

List<ENSessionFindNotesResult> myResultsList = ENSession.SharedSession.FindNotes(ENNoteSearch.NoteSearch(textToFind), null, ENSession.SearchScope.All, ENSession.SortOrder.RecentlyUpdated, 500);
int noteCount = 0;
if (myResultsList.Count > 0)
{
foreach (ENSessionFindNotesResult result in myResultsList)
{
if(string.Equals( result.Title,textToFind)) {
noteCount += 1;
}
}
}
Assert.IsTrue(noteCount == 1, "Either search failed or returned more results.");
}
}
}
28 changes: 28 additions & 0 deletions src/EvernoteSDK.Tests/ENSession_ShareNote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace EvernoteSDK.Tests
{
[TestClass]
public class ENSession_ShareNote
{
[TestInitialize]
public void Initialize()
{
TestUtils.AuthenticateToEverNote();
}

[TestMethod]
public void WhenSharingSimpleNote_ShouldReturnSharedNoteUrl()
{
ENNote myPlainNote = new ENNote();
myPlainNote.Title = "My plain text note to share";
myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello, world! I am sharing");
ENNoteRef myPlainNoteRef = ENSession.SharedSession.UploadNote(myPlainNote, null);

// Share this new note publicly. "shareUrl" is the public URL to distribute to access the note.
string shareUrl = ENSession.SharedSession.ShareNote(myPlainNoteRef);
Assert.IsFalse(string.IsNullOrWhiteSpace(shareUrl), "Not able to obtain shared note url");
}
}
}
50 changes: 50 additions & 0 deletions src/EvernoteSDK.Tests/ENSession_UploadNote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace EvernoteSDK.Tests
{
[TestClass]
public class ENSession_UploadNote
{
[TestInitialize]
public void Initialize()
{
TestUtils.AuthenticateToEverNote();
}
[TestMethod]
public void WhenContentIsSimpleText_ShouldSucceed()
{
// Get a list of all notebooks in the user's account.
List<ENNotebook> myNotebookList = ENSession.SharedSession.ListNotebooks();

// Create a new note (in the user's default notebook) with some plain text content.
ENNote myPlainNote = new ENNote();
myPlainNote.Title = "My plain text note";
myPlainNote.Content = ENNoteContent.NoteContentWithString("Hello, world!");
ENNoteRef myPlainNoteRef = ENSession.SharedSession.UploadNote(myPlainNote, null);
}
[TestMethod]
public void WhenContentIsHtml_ShouldSucceed()
{
// Create a new note (in the user's default notebook) with some HTML content.
ENNote myFancyNote = new ENNote();
myFancyNote.Title = "My first note";
myFancyNote.Content = ENNoteContent.NoteContentWithSanitizedHTML("<p>Hello, world - <i>this</i> is a <b>fancy</b> note - and here is a table:</p><br /> <br/><table border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\"><tr><td>Red</td><td>Green</td></tr><tr><td>Blue</td><td>Yellow</td></tr></table>");
ENNoteRef myFancyNoteRef = ENSession.SharedSession.UploadNote(myFancyNote, null);
}

[TestMethod]
public void WhenNoteContainsResource_ShouldSucceed()
{
// Create a new note with a resource.
ENNote myResourceNote = new ENNote();
myResourceNote.Title = "My test note with a resource";
myResourceNote.Content = ENNoteContent.NoteContentWithString("Hello, resource!");
byte[] myFile = TestUtils.StreamFile(TestConfiguration.PathToJPEGFile);
ENResource myResource = new ENResource(myFile, "image/jpg", "My First Picture.jpg");
myResourceNote.Resources.Add(myResource);
ENNoteRef myResourceRef = ENSession.SharedSession.UploadNote(myResourceNote, null);

}
}
}
Loading