Skip to content
Merged
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
469 changes: 301 additions & 168 deletions README.md

Large diffs are not rendered by default.

50 changes: 0 additions & 50 deletions src/Intercom.Tests.Integration/Intercom.Integration.Tests.csproj

This file was deleted.

16 changes: 16 additions & 0 deletions src/Intercom.Tests.Integration/Intercom.Tests.Integration.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<ReleaseVersion>2.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Intercom\Intercom.csproj" />
</ItemGroup>
</Project>
Empty file modified src/Intercom.Tests.Integration/Test.cs
100644 → 100755
Empty file.
Empty file modified src/Intercom.Tests.Integration/TestBase.cs
100644 → 100755
Empty file.
4 changes: 0 additions & 4 deletions src/Intercom.Tests.Integration/packages.config

This file was deleted.

6 changes: 2 additions & 4 deletions src/Intercom.Tests/Clients/AdminClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@ public AdminClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void View_WithEmptyString_ThrowException()
{
adminsClient.View(String.Empty);
Assert.Throws<ArgumentNullException>(() => adminsClient.View(String.Empty));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void View_NoId_ThrowException()
{
adminsClient.View(new Admin());
Assert.Throws<ArgumentException>(() => adminsClient.View(new Admin()));
}
}
}
9 changes: 3 additions & 6 deletions src/Intercom.Tests/Clients/AdminConversationsClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,21 @@ public AdminConversationsClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Reply_WithNull_ThrowException()
{
adminConversationsClient.Reply(null);
Assert.Throws<ArgumentNullException>(() => adminConversationsClient.Reply(null));
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
adminConversationsClient.Create(null);
Assert.Throws<ArgumentNullException>(() => adminConversationsClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void List_NoId_ThrowException()
{
adminConversationsClient.List(new Admin());
Assert.Throws<ArgumentException>(() => adminConversationsClient.List(new Admin()));
}
}
}
20 changes: 11 additions & 9 deletions src/Intercom.Tests/Clients/CompanyClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,40 @@ public CompanyClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
companyClient.Create(null);
Assert.Throws<ArgumentNullException>(() => companyClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Delete_MoreThan100CustomAtt_ThrowException()
{
Dictionary<string, object> custom_attributes = new Dictionary<string, object>();

for (int i = 0; i < 105; i++)
custom_attributes.Add("field", "value");
custom_attributes.Add($"field{i}", "value");

companyClient.Create(new Company() { custom_attributes = custom_attributes } );
Assert.Throws<ArgumentException>(() =>
{
companyClient.Create(new Company() { custom_attributes = custom_attributes });
});
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Create_CustomAttInvalidChars_ThrowException()
{
Dictionary<string, object> custom_attributes = new Dictionary<string, object>();
custom_attributes.Add("invalid.ch$ar", "invalid");
companyClient.Create(new Company() { custom_attributes = custom_attributes } );
Assert.Throws<ArgumentException>(() =>
{
companyClient.Create(new Company() { custom_attributes = custom_attributes });
});
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Update_WithNull_ThrowException()
{
companyClient.Update(null);
Assert.Throws<ArgumentNullException>(() => companyClient.Update(null));
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think we need to add a test for something like plan here? just wondering since the way plan is a string and returns an object, it caused issues before. Maybe now is not the time? but it would be good to try and catch edge cases like that i.e. create company without plan and with plan tests to make sure they work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to revamp our testing and it's definitely something I wanna add in the roadmap. But for this PR decided not too change too many things, the specs were only changed to conform to the new NUnit specs.

12 changes: 4 additions & 8 deletions src/Intercom.Tests/Clients/ContactClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,27 @@ public ContactClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
contactsClient.Create(null);
Assert.Throws<ArgumentNullException>(() => contactsClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Update_NoIdOrUserIdOrEmail_ThrowException()
{
contactsClient.Update(new Contact());
Assert.Throws<ArgumentException>(() => contactsClient.Update(new Contact()));
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void ListByEmail_NoEmail_ThrowException()
{
contactsClient.List(String.Empty);
Assert.Throws<ArgumentNullException>(() => contactsClient.List(String.Empty));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Delete_NoIdOrUserIdOrEmail_ThrowException()
{
contactsClient.Delete(new Contact());
Assert.Throws<ArgumentException>(() => contactsClient.Delete(new Contact()));
}
}
}
3 changes: 1 addition & 2 deletions src/Intercom.Tests/Clients/ConversationsClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ public ConversationsClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void View_WithNull_ThrowException()
{
conversationsClient.View(null);
Assert.Throws<ArgumentNullException>(() => conversationsClient.View(null));
}
}
}
9 changes: 3 additions & 6 deletions src/Intercom.Tests/Clients/EventsClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,21 @@ public EventsClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
eventsClient.Create(null);
Assert.Throws<ArgumentNullException>(() => eventsClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void List_NoIdOrUserIdOrEmail_ThrowException()
{
eventsClient.List(new User());
Assert.Throws<ArgumentException>(() =>eventsClient.List(new User()));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void ListByParams_NoIdOrUserIdOrEmail_ThrowException()
{
eventsClient.List(new Dictionary<String,String>());
Assert.Throws<ArgumentException>(() => eventsClient.List(new Dictionary<String,String>()));
}
}
}
24 changes: 12 additions & 12 deletions src/Intercom.Tests/Clients/NotesClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,45 +23,45 @@ public NotesClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
notesClient.Create(null);
Assert.Throws<ArgumentNullException>(() => notesClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void CreateWithNote_NoUserIdOrEmail_ThrowException()
{
notesClient.Create(new Note() { user = new User() });
Assert.Throws<ArgumentException>(() => notesClient.Create(new Note() { user = new User() }));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void CreateWithNote_NoBody_ThrowException()
{
notesClient.Create(new Note() { user = new User() { email = "email@example.com" } });
Assert.Throws<ArgumentException>(() =>
{
notesClient.Create(new Note() { user = new User() { email = "email@example.com" } });
});
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Create_NoUserIdOrEmail_ThrowException()
{
notesClient.Create(new User(), String.Empty);
Assert.Throws<ArgumentException>(() => notesClient.Create(new User(), String.Empty));
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_NoBody_ThrowException()
{
notesClient.Create(new User() { email = "email@example.com" }, String.Empty);
Assert.Throws<ArgumentNullException>(() =>
{
notesClient.Create(new User() { email = "email@example.com" }, String.Empty);
});
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void List_NoIdOrUserIdOrEmail_ThrowException()
{
notesClient.List(new User());
Assert.Throws<ArgumentException>(() => notesClient.List(new User()));
}
}
}
Empty file modified src/Intercom.Tests/Clients/SegmentsClientTest.cs
100644 → 100755
Empty file.
12 changes: 4 additions & 8 deletions src/Intercom.Tests/Clients/TagsClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,28 @@ public TagsClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
tagsClient.Create(null);
Assert.Throws<ArgumentNullException>(() => tagsClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Create_NoIdOrName_ThrowException()
{
tagsClient.Create(new Tag());
Assert.Throws<ArgumentException>(() => tagsClient.Create(new Tag()));
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Delete_WithNull_ThrowException()
{
Tag tag = null;
tagsClient.Delete(tag);
Assert.Throws<ArgumentNullException>(() => tagsClient.Delete(tag));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Delete_NoId_ThrowException()
{
tagsClient.Delete(new Tag());
Assert.Throws<ArgumentException>(() => tagsClient.Delete(new Tag()));
}


Expand Down
12 changes: 4 additions & 8 deletions src/Intercom.Tests/Clients/UserClientTest.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,27 @@ public UserClientTest()
}

[Test()]
[ExpectedException(typeof(ArgumentNullException))]
public void Create_WithNull_ThrowException()
{
usersClient.Create(null);
Assert.Throws<ArgumentNullException>(() => usersClient.Create(null));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Create_NoUserIdOrEmail_ThrowException()
{
usersClient.Create(new User());
Assert.Throws<ArgumentException>(() => usersClient.Create(new User()));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Delete_NoIdOrUserIdOrEmail_ThrowException()
{
usersClient.Delete(new User());
Assert.Throws<ArgumentException>(() => usersClient.Delete(new User()));
}

[Test()]
[ExpectedException(typeof(ArgumentException))]
public void Update_NoIdOrUserIdOrEmail_ThrowException()
{
usersClient.Update(new User());
Assert.Throws<ArgumentException>(() => usersClient.Update(new User()));
}
}
}
Loading