Created
March 20, 2020 10:45
-
-
Save mrtank/0c88027ac784a1321e38464da967bea0 to your computer and use it in GitHub Desktop.
test architecture
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
namespace ThickClient.SequentialNumber.Tests | |
{ | |
... | |
[TestClass] | |
public class SequentialProviderTest | |
{ | |
[TestMethod] | |
public void CreatsEmptyFile() | |
{ | |
// Arrange | |
Mock<IFileSystem> mock = new Mock<IFileSystem>(MockBehavior.Strict); | |
mock.Setup(x => x.ReadAllText(_filePath)).Throws<FileNotFoundException>(); | |
// Act | |
SequentialProviderMock sequentialProvider = new SequentialProviderMock(mock.Object); | |
// Assert | |
sequentialProvider.GetCurrent().Root.HasElements.Should().BeFalse(); | |
mock.VerifyAll(); | |
} | |
... | |
[TestMethod] | |
public void NextingEmpty() | |
{ | |
// Arrange | |
Mock<IFileSystem> mock = new Mock<IFileSystem>(MockBehavior.Strict); | |
mock.Setup(x => x.ReadAllText(_filePath)).Throws<FileNotFoundException>(); | |
mock.Setup(x => x.WriteAllText(_filePath, It.IsAny<string>())); | |
SequentialProviderMock sequentialProvider = new SequentialProviderMock(mock.Object); | |
// Act | |
decimal result = sequentialProvider.NextTicket(); | |
// Assert | |
result.ShouldBeEquivalentTo(-1M); | |
XElement root = sequentialProvider.GetCurrent().Root; | |
root.Should().HaveElement(SequentialProvider.NodeNamesForLevel[0]); | |
XElement first = (XElement)root.FirstNode; | |
first.Should().HaveAttribute("sequenceNumber", "-1"); | |
mock.VerifyAll(); | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment