Something went wrong. Try again.
Event Sourcing Framework on top of Microsoft Orleans and PostgreSQL
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263// NOTE BEST PRACTICE// The namespace of the tests and of the "system under test" (SuT) are the same after the assembly prefix.// To avoid name conflicts use a "using alias" for the SuT.using SuT = Flensrocker.ToDo.Abstractions.Tasks.TaskCommand;
namespace Flensrocker.ToDo.UnitTests.Tasks.TaskCommand;
[TestClass]public sealed class OpenCommandTests{ [TestMethod] [DataRow("Valid Title")] [DataRow("max length 23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567890")] public void GivenValidInputsThenReturnSuccess(string validTitle) { var testResult = SuT.Open.Create(title: validTitle);
var result = Assert.IsInstanceOfType<DomainResult<SuT.Open>.Success>(testResult); Assert.AreEqual(validTitle, result.Value.Title); }
[TestMethod] [DataRow("Whitespace at end ", "Whitespace at end")] [DataRow(" Whitespace at front", "Whitespace at front")] [DataRow(" Whitespace at front and end ", "Whitespace at front and end")] [DataRow( " max length 23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567890", "max length 23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567890" )] public void GivenValidButDirtyInputsThenReturnSuccessWithSanitizedValues(string title, string expectedTitle) { var testResult = SuT.Open.Create(title: title);
var result = Assert.IsInstanceOfType<DomainResult<SuT.Open>.Success>(testResult); Assert.AreEqual(expectedTitle, result.Value.Title); }
[TestMethod] [DataRow((string?)null)] [DataRow("")] [DataRow(" ")] [DataRow("\t")] [DataRow(" \t")] [DataRow("\t ")] [DataRow(" \t ")] [DataRow("123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 1")] [DataRow("With\nLinebreak")] [DataRow("With\rCarriage Return")] public void GivenInvalidInputsThenReturnValidationProblem(string? invalidTitle) { var testResult = SuT.Open.Create(title: invalidTitle);
var result = Assert.IsInstanceOfType<DomainResult<SuT.Open>.ValidationProblem>(testResult); Assert.IsTrue(result.Errors.ContainsKey(nameof(SuT.Open.Title))); }
[TestMethod] public void IsJsonSerializable() { ToDoTestUtilities.AssertJsonSerializable<SuT, SuT.Open>(SuT.Open.Create(title: "Some Title")); }}