Beispiel #1
0
        private static Answer CreateAFakeAnswer(DateTimeOffset questionCreatedOn, IList <User> users)
        {
            var userId = users.ToRandomList(1).Single().Id;
            var answer = Builder <Answer>
                         .CreateNew()
                         .With(x => x.Content        = GetRandom.Phrase(GetRandom.Int(20, 100)))
                         .And(x => x.CreatedOn       = GetRandom.DateTime(questionCreatedOn.DateTime.AddMinutes(5), DateTime.UtcNow))
                         .And(x => x.CreatedByUserId = userId)
                         .And(x => x.Stats           = CreateAFakeStats())
                         .Build();

            for (int i = 0; i < (GetRandom.PositiveInt(20) <= 10 ? GetRandom.PositiveInt(6) : 0); i++)
            {
                if (answer.Comments == null)
                {
                    answer.Comments = new List <Comment>();
                }
                answer.Comments.Add(CreateAFakeComment(questionCreatedOn.DateTime, users.ToRandomList(1).Single().Id));
            }

            if (answer.Comments == null)
            {
                answer.Comments = new List <Comment>();
            }

            return(answer);
        }
        public void DateTime_returns_expected_DateTime_when_minValue_and_maxValue_are_the_same()
        {
            var expected = GetRandom.DateTime();
            var actual   = GetRandom.DateTime(expected, expected);

            actual.ShouldBe(expected);
        }
        protected object createRandomDebitCardViewModel()
        {
            var v = GetRandom.Object <DebitCardView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            return(v);
        }
        protected override object createRandomViewModel()
        {
            var v = GetRandom.Object <CheckView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            return(v);
        }
        public void DateTime_returns_random_DateTime_less_than_maxValue()
        {
            var maxValue = GetRandom.DateTime();
            var actual   = GetRandom.DateTime(maxValue);

            actual.ShouldBeLessThanOrEqualTo(maxValue);
        }
Beispiel #6
0
 private void initializeTestData()
 {
     rate     = GetRandom.Decimal(1, 10);
     currency = new Currency(GetRandom.Object <CurrencyData>());
     rateType = new RateType(GetRandom.Object <RateTypeData>());
     date     = GetRandom.DateTime();
 }
Beispiel #7
0
        public void IsNotEqualTest()
        {
            var x = GetRandom.DateTime();

            Assert.IsTrue(Obj.IsNotEqual(x));
            Assert.IsFalse(Obj.IsNotEqual(Obj.Value));
        }
Beispiel #8
0
        public void IsNotGreaterTest()
        {
            var x = GetRandom.DateTime(max: Obj.Value);

            Assert.IsFalse(Obj.IsNotGreater(x));
            Assert.IsTrue(Obj.IsNotGreater(Obj.Value));
        }
Beispiel #9
0
        public void DateTest()
        {
            var d = GetRandom.DateTime();

            obj.Date = d;
            Assert.AreEqual(obj.Date, d);
        }
Beispiel #10
0
        public void Should_ReturnMailingHistoryOfSpecifiedPerson_WhenRequested()
        {
            // arrange
            var person = Builder <Person> .CreateNew()
                         .With(x => x.Id = 7777).Build();

            var mails = Builder <MailMessage> .CreateListOfSize(25)
                        .All().With(x => x.Date           = GetRandom.DateTime())
                        .With(x => x.Sender               = Builder <Person> .CreateNew().Build())
                        .With(x => x.Receivers            = Builder <Person> .CreateListOfSize(3).Build())
                        .TheFirst(7).With(x => x.Sender   = person)
                        .TheLast(7).With(x => x.Receivers = new List <Person> {
                person
            })
                        .Build();

            var repository = Substitute.For <IRepository>();

            repository.Query <MailMessage>().ReturnsForAnyArgs(mails.AsQueryable());
            var clientController = new ClientsController(repository);

            // act
            var viewResult = (IList <MailMessage>)clientController.MailingHistory(7777).Model;

            // assert
            viewResult.Count().Should().Be(14);

            for (int i = 1; i < viewResult.Count; i++)
            {
                viewResult[i].Date.Should().BeOnOrAfter(viewResult[i - 1].Date);
            }
        }
Beispiel #11
0
        private static Question CreateAFakeQuestion(IList <User> users)
        {
            var user         = users.ToRandomList(1).Single();
            var fakeQuestion = Builder <Question>
                               .CreateNew()
                               .With(x => x.Id       = null)
                               .With(x => x.Subject  = GetRandom.Phrase(GetRandom.Int(10, 50)))
                               .With(x => x.Content  = GetRandom.Phrase(GetRandom.Int(30, 500)))
                               .And(x => x.CreatedBy = user.Id)
                               .And(x => x.CreatedOn = GetRandom.DateTime(DateTime.UtcNow.AddMonths(-1), DateTime.UtcNow.AddMinutes(-5)))
                               .And(x => x.Tags      = FakeTags.ToRandomList(GetRandom.Int(1, 5)))
                               .And(x => x.Stats     = CreateAFakeStats())
                               .Build();

            for (int i = 0; i < (GetRandom.Int(1, 20) <= 10 ? GetRandom.PositiveInt(6) : 0); i++)
            {
                if (fakeQuestion.Answers == null)
                {
                    fakeQuestion.Answers = new List <Answer>();
                }

                fakeQuestion.Answers.Add(CreateAFakeAnswer(fakeQuestion.CreatedOn, users));
            }

            if (fakeQuestion.Answers == null)
            {
                fakeQuestion.Answers = new List <Answer>();
            }

            return(fakeQuestion);
        }
Beispiel #12
0
        public void CommentAddTimeTest()
        {
            DateTime rnd() => GetRandom.DateTime(null, obj.CommentAddTime);

            testReadWriteProperty(() => obj.CommentAddTime,
                                  x => obj.CommentAddTime = x, rnd);
        }
Beispiel #13
0
        public void ConvertTest()
        {
            var x = GetRandom.DateTime();
            var s = x.ToString("s");

            Assert.AreEqual(x.ToString(UseCulture.Invariant), Obj.Convert(s).ToString(UseCulture.Invariant));
        }
 public static ItemBuilder Typical()
 {
     return(Simple()
            .WithDescription(() => GetRandom.String(1, 150))
            .WithAddedDate(GetRandom.DateTime())
            .WithQuantity(GetRandom.Int16(10)));
 }
Beispiel #15
0
        protected virtual void setRandomValues(TObject o)
        {
            var r = getData(o);

            r.ValidFrom = GetRandom.DateTime(maxValue: r.ValidTo);
            r.ValidTo   = GetRandom.DateTime(r.ValidFrom);
        }
Beispiel #16
0
        public static Question CreateAFakeQuestion(string userId, IList <string> answerUserIds)
        {
            Question fakeQuestion = Builder <Question>
                                    .CreateNew()
                                    .With(x => x.Id      = null)
                                    .With(x => x.Subject = GetRandom.Phrase(GetRandom.Int(10, 50)))
                                    .With(x => x.Content = GetRandom.Phrase(GetRandom.Int(30, 500)))
                                    .And(
                x =>
                x.CreatedByUserId =
                    string.IsNullOrEmpty(userId) ? null : userId)
                                    .And(
                x => x.CreatedOn = GetRandom.DateTime(DateTime.UtcNow.AddMonths(-1), DateTime.UtcNow.AddMinutes(-5)))
                                    .And(x => x.NumberOfViews = GetRandom.PositiveInt(10000))
                                    .And(x => x.Tags          = FakeTags.ToRandomList(GetRandom.Int(1, 5)))
                                    .And(x => x.Vote          = CreateAFakeVote())
                                    .Build();

            for (int i = 0; i < (GetRandom.Int(1, 20) <= 10 ? GetRandom.PositiveInt(6) : 0); i++)
            {
                if (fakeQuestion.Answers == null)
                {
                    fakeQuestion.Answers = new List <Answer>();
                }

                fakeQuestion.Answers.Add(CreateAFakeAnswer(fakeQuestion.CreatedOn,
                                                           answerUserIds.ToRandomList(1).Single()));
            }

            return(fakeQuestion);
        }
Beispiel #17
0
        protected override object createRandomViewModel()
        {
            var v = GetRandom.Object <GeographicAddressView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            return(v);
        }
Beispiel #18
0
        public void IsNotLessTest()
        {
            var x = GetRandom.DateTime(Obj.Value);

            Assert.IsFalse(Obj.IsNotLess(x));
            Assert.IsTrue(Obj.IsNotLess(Obj.Value));
        }
Beispiel #19
0
        [TestMethod] public void DateTest()
        {
            var dt = GetRandom.DateTime();
            var m  = new Money(null, 0, dt);

            Assert.AreEqual(dt, m.Date);
        }
        [TestMethod] public void DateWrittenTest()
        {
            DateTime?rnd() => GetRandom.DateTime(null, obj.ValidTo?.AddYears(-1));

            Assert.AreEqual(obj.ValidFrom, obj.DateWritten);
            obj.DateWritten = rnd();
            Assert.AreEqual(obj.ValidFrom, obj.DateWritten);
        }
Beispiel #21
0
        protected object createRandomWebViewModel()
        {
            var v = GetRandom.Object <WebPageAddressView>();

            v.Url     = GetRandom.String() + "." + GetRandom.String(2, 2);
            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            return(v);
        }
Beispiel #22
0
        public void TestProperty(Func <DateTime> get, Action <DateTime> set)
        {
            var s = GetRandom.DateTime();

            Assert.AreNotEqual(s, get());
            set(s);
            Assert.AreEqual(s, get());
        }
Beispiel #23
0
        [TestMethod] public void ValueTests()
        {
            var d = GetRandom.DateTime();

            obj.Value = d;
            Assert.AreEqual(d.ToString(UseCulture.Invariant), obj.Value.ToString(UseCulture.Invariant));
            Assert.AreEqual(d.ToString(UseCulture.Invariant), obj.ValueAsString);
        }
Beispiel #24
0
        protected object createRandomEmailViewModel()
        {
            var v = GetRandom.Object <EMailAddressView>();

            v.EmailAddress = GetRandom.String() + "@" + GetRandom.String() + "." +
                             GetRandom.String(2, 2);
            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            return(v);
        }
        [TestMethod] public void ToDateTimeVariableTest()
        {
            var name  = GetRandom.String();
            var value = GetRandom.DateTime();
            var a     = Operand.ToVariable(name, value) as DateTimeVariable;

            Assert.AreEqual(name, a.Name);
            Assert.AreEqual(value, a.Value);
        }
        protected object createRandomViewModel()
        {
            var v = GetRandom.Object <AccountView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            addAspNetUser(v.AspNetUserId);
            v.AspNetUser = db.Users.Find(v.AspNetUserId);
            return(v);
        }
        protected override object createRandomViewModel()
        {
            var v = GetRandom.Object <PaymentView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            addCurrency(v.CurrencyID);
            addPaymentMethod(v.PaymentMethodID);
            return(v);
        }
        public void CreateGeographicAddressTest()
        {
            var v = GetRandom.Object <GeographicAddressView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            var o = AddressViewFactory.Create(v);

            validateAdr(o.Data, v);
        }
        public void CreateWebPageAddressTest()
        {
            var v = GetRandom.Object <WebPageAddressView>();

            v.ValidTo = GetRandom.DateTime(v.ValidFrom);
            var o = AddressViewFactory.Create(v);

            validateWeb(o.Data, v);
        }
        protected object createRandomViewModel()
        {
            var v = GetRandom.Object <WelcomeNotificationView>();

            v.ValidTo           = GetRandom.DateTime(v.ValidFrom);
            v.SenderAccountId   = "systemAccount";
            v.ReceiverAccountId = account.ID;
            return(v);
        }