-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f490325
commit 2a37d40
Showing
4 changed files
with
87 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using Mailosaur.Models; | ||
using Xunit; | ||
|
||
namespace Mailosaur.Test | ||
{ | ||
public class ErrorsTests | ||
{ | ||
[Fact] | ||
public void UnauthorizedTest() | ||
{ | ||
var client = new MailosaurClient("invalid_key"); | ||
var ex = Assert.Throws<MailosaurException>(delegate | ||
{ | ||
client.Servers.List(); | ||
}); | ||
|
||
Assert.Equal("Authentication failed, check your API key.", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public void NotFoundTest() | ||
{ | ||
var client = new MailosaurClient(Environment.GetEnvironmentVariable("MAILOSAUR_API_KEY")); | ||
var ex = Assert.Throws<MailosaurException>(delegate | ||
{ | ||
client.Servers.Get("not_found"); | ||
}); | ||
|
||
Assert.Equal("Not found, check input parameters.", ex.Message); | ||
} | ||
|
||
[Fact] | ||
public void BadRequestTest() | ||
{ | ||
var client = new MailosaurClient(Environment.GetEnvironmentVariable("MAILOSAUR_API_KEY")); | ||
var options = new ServerCreateOptions(""); | ||
var ex = Assert.Throws<MailosaurException>(delegate | ||
{ | ||
client.Servers.Create(options); | ||
}); | ||
|
||
Assert.Equal("(name) Please provide a name for your server\r\n", ex.Message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Mailosaur.Models | ||
{ | ||
using System.Collections.Generic; | ||
|
||
public class ErrorResponse | ||
{ | ||
public IList<Error> Errors { get; set; } | ||
} | ||
|
||
public class Error | ||
{ | ||
public string Field { get; set; } | ||
public IList<ErrorDetail> Detail { get; set; } | ||
} | ||
|
||
public class ErrorDetail | ||
{ | ||
public string Description { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters