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); }
private void initializeTestData() { rate = GetRandom.Decimal(1, 10); currency = new Currency(GetRandom.Object <CurrencyData>()); rateType = new RateType(GetRandom.Object <RateTypeData>()); date = GetRandom.DateTime(); }
public void IsNotEqualTest() { var x = GetRandom.DateTime(); Assert.IsTrue(Obj.IsNotEqual(x)); Assert.IsFalse(Obj.IsNotEqual(Obj.Value)); }
public void IsNotGreaterTest() { var x = GetRandom.DateTime(max: Obj.Value); Assert.IsFalse(Obj.IsNotGreater(x)); Assert.IsTrue(Obj.IsNotGreater(Obj.Value)); }
public void DateTest() { var d = GetRandom.DateTime(); obj.Date = d; Assert.AreEqual(obj.Date, d); }
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); } }
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); }
public void CommentAddTimeTest() { DateTime rnd() => GetRandom.DateTime(null, obj.CommentAddTime); testReadWriteProperty(() => obj.CommentAddTime, x => obj.CommentAddTime = x, rnd); }
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))); }
protected virtual void setRandomValues(TObject o) { var r = getData(o); r.ValidFrom = GetRandom.DateTime(maxValue: r.ValidTo); r.ValidTo = GetRandom.DateTime(r.ValidFrom); }
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); }
protected override object createRandomViewModel() { var v = GetRandom.Object <GeographicAddressView>(); v.ValidTo = GetRandom.DateTime(v.ValidFrom); return(v); }
public void IsNotLessTest() { var x = GetRandom.DateTime(Obj.Value); Assert.IsFalse(Obj.IsNotLess(x)); Assert.IsTrue(Obj.IsNotLess(Obj.Value)); }
[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); }
protected object createRandomWebViewModel() { var v = GetRandom.Object <WebPageAddressView>(); v.Url = GetRandom.String() + "." + GetRandom.String(2, 2); v.ValidTo = GetRandom.DateTime(v.ValidFrom); return(v); }
public void TestProperty(Func <DateTime> get, Action <DateTime> set) { var s = GetRandom.DateTime(); Assert.AreNotEqual(s, get()); set(s); Assert.AreEqual(s, get()); }
[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); }
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); }