public void HasUncommittedEvents_DiffrentEventValues_DisplayedInTheMessage()
        {
            using (CultureInfoScope.NewInvariant())
            {
                var buffer = EventBuffer.Empty(Guid.NewGuid())
                             .Add(new object[]
                {
                    new EmptyEvent(),
                    new Complex {
                        Value = 17, Message = "Same", Date = new DateTime(2017, 06, 11)
                    },
                    new SimpleEvent(),
                });

                var x = Assert.Catch <AssertionFailed>(() =>
                                                       AggregateRootAssert.HasUncommittedEvents(buffer,
                                                                                                new EmptyEvent(),
                                                                                                new Complex {
                    Value = 23, Message = "Same", Date = new DateTime(1980, 06, 30)
                },
                                                                                                new SimpleEvent()
                                                                                                ));

                Assert.AreEqual(@"Assertion failed:
[0] EmptyEvent
[1] Expected: { Value: 23, Date: 06/30/1980 00:00:00 }
    Actual:   { Value: 17, Date: 06/11/2017 00:00:00 }
[2] SimpleEvent
", x.Message);
            }
        }
Beispiel #2
0
 public void IsMatch(string pattern, string input, bool isMatch, WildcardPatternOptions options = default, StringComparison comparsionType = default, string culture = null)
 {
     using (culture is null ? CultureInfoScope.NewInvariant() : new CultureInfoScope("tr-TR"))
     {
         var actual = WildcardPattern.IsMatch(pattern, input, options, comparsionType);
         Assert.AreEqual(isMatch, actual, "'{0}' should {2} match '{1}', with {3} and {4}.", pattern, input, isMatch ? "" : "not ", options, comparsionType);
     }
 }
Beispiel #3
0
 public void IsValid_Data_IsTrue()
 {
     using (CultureInfoScope.NewInvariant())
     {
         Assert.IsTrue(StreamSize.IsValid("19 MB"));
         Assert.IsTrue(StreamSize.IsValid("1,456.134 MB"));
     }
 }
Beispiel #4
0
 public void TyrParse_StringValue_IsValid()
 {
     using (CultureInfoScope.NewInvariant())
     {
         string str = "14.1804";
         Assert.IsTrue(Amount.TryParse(str, out Amount val), "Valid");
         Assert.AreEqual(str, val.ToString(), "Value");
     }
 }
Beispiel #5
0
        public void ToString_CustomFormatter_SupportsCustomFormatting()
        {
            using (CultureInfoScope.NewInvariant())
            {
                var act = TestStruct.ToString("Unit Test Format", new UnitTestFormatProvider());
                var exp = "Unit Test Formatter, value: 'Male', format: 'Unit Test Format'";

                Assert.AreEqual(exp, act);
            }
        }
        public void Validate_ModelWithMandatoryProperties_WithErrors()
        {
            using (CultureInfoScope.NewInvariant())
            {
                var model = new ModelWithMandatoryProperties();

                DataAnnotationsAssert.WithErrors(model,
                                                 ValidationTestMessage.Error("The E-mail address field is required.", "Email"),
                                                 ValidationTestMessage.Error("The SomeString field is required.", "SomeString")
                                                 );
            }
        }
Beispiel #7
0
        public void Format_ComplexPatternWithUnitTestFormatProvider_AreEqual()
        {
            using (CultureInfoScope.NewInvariant())
            {
                var collection = new FormattingArgumentsCollection(new UnitTestFormatProvider());
                collection.Add(typeof(Date), "yyyy-MM-dd HH:mm");
                collection.Add(typeof(Decimal), "0.000");

                var act = collection.Format("{0:yyyy-MM-dd} * {0}", new Date(2014, 10, 8));
                var exp = "Unit Test Formatter, value: '10/08/2014', format: 'yyyy-MM-dd' * Unit Test Formatter, value: '10/08/2014', format: ''";

                Assert.AreEqual(exp, act);
            }
        }
Beispiel #8
0
        public void Format_ComplexPattern_AreEqual()
        {
            using (CultureInfoScope.NewInvariant())
            {
                var collection = new FormattingArgumentsCollection(new CultureInfo("nl-BE"));
                collection.Add(typeof(Date), "yyyy-MM-dd HH:mm");
                collection.Add(typeof(Decimal), "0.000");

                var act = collection.Format("{0:000.00} - {1} * {1:dd-MM-yyyy} - {2} - {3} - {4}", 3, new Date(2014, 10, 8), 666, 0.8m, 0.9);
                var exp = "003,00 - 2014-10-08 00:00 * 08-10-2014 - 666 - 0,800 - 0,9";

                Assert.AreEqual(exp, act);
            }
        }
Beispiel #9
0
        public void IsValid_Data_IsFalse()
        {
            using (CultureInfoScope.NewInvariant())
            {
                Assert.IsFalse(StreamSize.IsValid("Complex"), "Complex");
                Assert.IsFalse(StreamSize.IsValid((String)null), "(String)null");
                Assert.IsFalse(StreamSize.IsValid(string.Empty), "string.Empty");

                Assert.IsFalse(StreamSize.IsValid("1234 EB"), "1234 EB, to big");
                Assert.IsFalse(StreamSize.IsValid("-1234EB"), "-1234EB, to small");

                Assert.IsFalse(StreamSize.IsValid("12.9 EB"), "12.9 EB, to big");
                Assert.IsFalse(StreamSize.IsValid("-12.9EB"), "-12.9EB, to small");

                Assert.IsFalse(StreamSize.IsValid("79,228,162,514,264,337,593,543,950,335 kB"), "12.9 EB, to big for decimal");
                Assert.IsFalse(StreamSize.IsValid("-9,228,162,514,264,337,593,543,950,335 kB"), "-12.9EB, to small for decimal");
            }
        }