public void Create() { var organisations = new Organisations(this.Session).Extent(); var organisation = organisations.First(v => v.PartyName.Equals("Acme0")); var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = allors.ActiveEmployees.First(v => v.FirstName.Equals("first")); var organisationAddress = new PostalAddressBuilder(this.Session) .WithAddress1("Haverwerf 15") .WithPostalBoundary(new PostalBoundaryBuilder(this.Session).WithLocality("city").WithPostalCode("1111").WithCountry(new Countries(this.Session).FindBy(M.Country.IsoCode, "BE")).Build()) .Build(); organisation.AddPartyContactMechanism(new PartyContactMechanismBuilder(this.Session).WithContactMechanism(organisationAddress).Build()); this.Session.Derive(); this.Session.Commit(); var before = new LetterCorrespondences(this.Session).Extent().ToArray(); var page = this.organisationListPage.Select(organisation).NewLetterCorrespondence(); page.EventState.Set(new CommunicationEventStates(this.Session).Completed.Name) .Purposes.Toggle(new CommunicationEventPurposes(this.Session).Appointment.Name) .FromParty.Set(organisation.PartyName) .ToParty.Set(employee.PartyName) .PostalAddress.Set("Haverwerf 15 1111 city Belgium") .Subject.Set("subject") .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .Comment.Set("comment") .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new LetterCorrespondences(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var communicationEvent = after.Except(before).First(); Assert.Equal(new CommunicationEventStates(this.Session).Completed, communicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Appointment, communicationEvent.EventPurposes); Assert.Equal(organisationAddress, communicationEvent.PostalAddress); Assert.Equal(organisation, communicationEvent.FromParty); Assert.Equal(employee, communicationEvent.ToParty); Assert.Equal("subject", communicationEvent.Subject); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date); Assert.Equal("comment", communicationEvent.Comment); }
public void Create() { var organisations = new Organisations(this.Session).Extent(); var organisation = organisations.First(v => v.PartyName.Equals("Acme0")); var contact = organisation.CurrentContacts.First; var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = allors.ActiveEmployees.First(v => v.FirstName.Equals("first")); var employeeEmailAddress = employee.PersonalEmailAddress; var personEmailAddress = organisation.CurrentContacts.First.PersonalEmailAddress; this.Session.Derive(); this.Session.Commit(); var before = new EmailCommunications(this.Session).Extent().ToArray(); var organisationOverviewPage = this.organisationListPage.Select(organisation); var page = organisationOverviewPage.NewEmailCommunication(); page.EventState.Set(new CommunicationEventStates(this.Session).Completed.Name) .Purposes.Toggle(new CommunicationEventPurposes(this.Session).Appointment.Name) .FromParty.Set(employee.PartyName) .FromEmail.Set(employeeEmailAddress.ElectronicAddressString) .ToParty.Set(contact.PartyName) .ToEmail.Set(personEmailAddress.ElectronicAddressString) .Subject.Set("subject") .Body.Set("body") .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new EmailCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var communicationEvent = after.Except(before).First(); Assert.Equal(new CommunicationEventStates(this.Session).Completed, communicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Appointment, communicationEvent.EventPurposes); Assert.Equal(employee, communicationEvent.FromParty); Assert.Equal(employeeEmailAddress, communicationEvent.FromEmail); Assert.Equal(contact, communicationEvent.ToParty); Assert.Equal(personEmailAddress, communicationEvent.ToEmail); Assert.Equal("subject", communicationEvent.EmailTemplate.SubjectTemplate); Assert.Equal("body", communicationEvent.EmailTemplate.BodyTemplate); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date); }
public async Task <CalendarItem> GetMonthInfoAsync(Func <Task <CalendarItem> > yearFunc) { return(await Task.Run(async() => { var yearInfo = await yearFunc().ConfigureAwait(false); var requestResult = DateTimeFactory.GetMonth(yearInfo.Stem.Id, _currentSeasonAngle, _solarCalendar).Sexagenary; return GetCalendarItem(requestResult); }) .ConfigureAwait(false)); }
/// <inheritdoc /> public override DailyAnswer ToDailyAnswer(int year) { return(DailyAnswerBuilder .Create(Name, HolidayType) .From(DateTimeFactory.FindLastDay(year, 10, DayOfWeek.Monday)) .Since(1977) .Country(Country.ToCode(), GetRegionCodeList()) .I18N(I18NIdentityCode) .Build(year)); }
private static Window Window(params ActivityEvent[] activityEvents) { var window = new Window(DateTimeFactory.SomeWorkingHoursDateTime(), TimeSpan.FromSeconds(5)); foreach (var activityEvent in activityEvents) { window.Add(activityEvent); } return(window); }
public void Create() { var person = new People(this.Session).Extent().First; var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = allors.ActiveEmployees.First(); var employeeEmailAddress = employee.PersonalEmailAddress; var personEmailAddress = person.PersonalEmailAddress; this.Session.Derive(); this.Session.Commit(); var before = new EmailCommunications(this.Session).Extent().ToArray(); this.personListPage.Table.DefaultAction(person); var emailCommunicationEdit = new PersonOverviewComponent(this.personListPage.Driver).CommunicationeventOverviewPanel.Click().CreateEmailCommunication(); emailCommunicationEdit .CommunicationEventState.Select(new CommunicationEventStates(this.Session).Completed) .EventPurposes.Toggle(new CommunicationEventPurposes(this.Session).Appointment) .FromParty.Select(employee) .FromEmail.Select(employeeEmailAddress) .ToParty.Select(person) .ToEmail.Select(personEmailAddress) .SubjectTemplate.Set("subject") .BodyTemplate.Set("body") .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new EmailCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var communicationEvent = after.Except(before).First(); Assert.Equal(new CommunicationEventStates(this.Session).Completed, communicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Appointment, communicationEvent.EventPurposes); Assert.Equal(employee, communicationEvent.FromParty); Assert.Equal(employeeEmailAddress, communicationEvent.FromEmail); Assert.Equal(person, communicationEvent.ToParty); Assert.Equal(personEmailAddress, communicationEvent.ToEmail); Assert.Equal("subject", communicationEvent.EmailTemplate.SubjectTemplate); Assert.Equal("body", communicationEvent.EmailTemplate.BodyTemplate); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date); }
/// <inheritdoc /> public override DailyAnswer ToDailyAnswer(int year) { var saturdayFunc = SaturdayShift == 0 ? Self() : Shift(SaturdayShift); var sundayFunc = SundayShift == 0 ? Self() : Shift(SundayShift); var calculationDay = DateTimeFactory .Create(year, Month, Day) .Shift(saturdayFunc, sundayFunc); if (MondayShift != 0) { calculationDay = calculationDay.MondayShift(Shift(MondayShift)); } if (TuesdayShift != 0) { calculationDay = calculationDay.TuesdayShift(Shift(TuesdayShift)); } if (WednesdayShift != 0) { calculationDay = calculationDay.WednesdayShift(Shift(WednesdayShift)); } if (ThursdayShift != 0) { calculationDay = calculationDay.ThursdayShift(Shift(ThursdayShift)); } if (FridayShift != 0) { calculationDay = calculationDay.FridayShift(Shift(FridayShift)); } var builder = DailyAnswerBuilder.Create(Name, HolidayType).From(calculationDay); if (Since.HasValue) { builder.Since(Since.Value); } if (End.HasValue) { builder.End(End.Value); } if (TimeStepValue.HasValue) { builder.Times(TimeStepValue.Value); } builder.Country(Country.ToCode(), GetRegionCodeList()); return(builder.I18N(I18NIdentityCode).Build(year)); }
public void TestSetTimeZone() { var factory = new DateTimeFactory(); var dto = factory.CreateDateTimeOffset(2017, 03, 03); var timeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"); var offset = timeZone.BaseUtcOffset - factory.TimeZone.BaseUtcOffset; var newDto = dto.SetTimeZone(timeZone); Assert.AreEqual(dto.DateTime, newDto.DateTime); Assert.AreEqual(dto - newDto, offset); }
public void ShouldDropMultipleEventsAfterLongBreak() { var someDateTime = DateTimeFactory.SomeWorkingHoursDateTime(); var eventBeforeBreak = TestEventFactory.SomeEvent(someDateTime); var firstEventAfterBreak = TestEventFactory.SomeEvent(someDateTime + _uut.LongBreak); var secondEventAfterBreak = TestEventFactory.SomeEvent(someDateTime + _uut.LongBreak); _uut.Map(eventBeforeBreak); _uut.Map(firstEventAfterBreak); Assert.AreEqual(Sets.NewHashSet <IDEEvent>(), _uut.Map(secondEventAfterBreak)); }
public object GetValue(object instance) { return(MemberName switch { "Name" => "Nice", "Length" => 10, "Width" => 100, "CreateTime" => DateTimeFactory.Create(2020, 12, 21), "Email" => "*****@*****.**", _ => default });
public void Return_Should_Be_DateTimeOffset_Utc() { // Assign var dateTimeFactory = new DateTimeFactory(); // Act var dateTime = dateTimeFactory.DateTimeOffsetUtc; // Assert Assert.IsType <DateTimeOffset>(dateTime); }
/// <inheritdoc /> public override DailyAnswer ToDailyAnswer(int year) { var calculationDay = DateTimeFactory.FindLastDay(year, 5, DayOfWeek.Monday); return(DailyAnswerBuilder .Create(Name, HolidayType) .From(calculationDay) .Country(Country.ToCode(), GetRegionCodeList()) .I18N(I18NIdentityCode) .Build(year)); }
public void Edit() { var organisations = new Organisations(this.Session).Extent(); var organisation = organisations.First(v => v.PartyName.Equals("Acme0")); var contact = organisation.CurrentContacts.First; var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var firstEmployee = allors.ActiveEmployees.First(v => v.FirstName.Equals("first")); var secondEmployee = allors.ActiveEmployees.First(v => v.FirstName.Equals("second")); var editCommunicationEvent = new FaceToFaceCommunicationBuilder(this.Session) .WithSubject("dummy") .WithFromParty(organisation.CurrentContacts.First) .WithToParty(firstEmployee) .WithLocation("old location") .Build(); this.Session.Derive(); this.Session.Commit(); var before = new FaceToFaceCommunications(this.Session).Extent().ToArray(); var page = this.organisationListPage.Select(organisation).SelectFaceToFaceCommunication(editCommunicationEvent); page.EventState.Set(new CommunicationEventStates(this.Session).Completed.Name) .Purposes.Toggle(new CommunicationEventPurposes(this.Session).Conference.Name) .Location.Set("new location") .Subject.Set("new subject") .FromParty.Set(secondEmployee.PartyName) .ToParty.Set(contact.PartyName) .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 24)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 24)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 24)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 24)) .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new FaceToFaceCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); Assert.Equal(new CommunicationEventStates(this.Session).Completed, editCommunicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Conference, editCommunicationEvent.EventPurposes); Assert.Equal(secondEmployee, editCommunicationEvent.FromParty); Assert.Equal(contact, editCommunicationEvent.ToParty); Assert.Equal("new location", editCommunicationEvent.Location); Assert.Equal("new subject", editCommunicationEvent.Subject); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ScheduledStart); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ScheduledEnd.Value.Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualStart.Value.Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualEnd.Value.Date); }
protected static Window Window(params Activity[] activities) { var window = new Window(DateTimeFactory.SomeWorkingHoursDateTime(), TimeSpan.FromSeconds(5)); foreach (var activityEvent in activities.Select(a => new ActivityEvent { Activity = a })) { window.Add(activityEvent); } return(window); }
public void Edit() { var person = new People(this.Session).Extent().First; var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var firstEmployee = allors.ActiveEmployees.First(); var before = new PhoneCommunications(this.Session).Extent().ToArray(); this.people.Table.DefaultAction(person); var personOverview = new PersonOverviewComponent(this.people.Driver); var communicationEventOverview = personOverview.CommunicationeventOverviewPanel.Click(); communicationEventOverview.Table.DefaultAction(this.editCommunicationEvent); var phoneCommunicationEditComponent = new PhoneCommunicationEditComponent(this.Driver); phoneCommunicationEditComponent .LeftVoiceMail.Set(false) .CommunicationEventState.Select(new CommunicationEventStates(this.Session).Completed) .EventPurposes.Toggle(new CommunicationEventPurposes(this.Session).Inquiry) .FromPhoneNumber.Select(this.anotherPhoneNumber.ContactMechanism) .Subject.Set("new subject") .FromParty.Select(firstEmployee) .ToParty.Select(person) .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 24)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 25)) .Comment.Set("new comment") .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new PhoneCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); Assert.False(this.editCommunicationEvent.LeftVoiceMail); Assert.Equal(new CommunicationEventStates(this.Session).Completed, this.editCommunicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Inquiry, this.editCommunicationEvent.EventPurposes); Assert.Equal(firstEmployee, this.editCommunicationEvent.FromParty); Assert.Equal(person, this.editCommunicationEvent.ToParty); Assert.Equal(this.anotherPhoneNumber.ContactMechanism, this.editCommunicationEvent.PhoneNumber); Assert.Equal("new subject", this.editCommunicationEvent.Subject); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ScheduledStart); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ScheduledEnd.Value.Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualStart.Value.Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualEnd.Value.Date); Assert.Equal("new comment", this.editCommunicationEvent.Comment); }
public void ShouldNotInsertDroppedEventsIfASecondLongBreakOccurs() { var someDateTime = DateTimeFactory.SomeWorkingHoursDateTime(); var eventBeforeBreak = TestEventFactory.SomeEvent(someDateTime); var droppedEvent = TestEventFactory.SomeEvent(someDateTime + _uut.LongBreak); var eventAfterSecondLongBreak = TestEventFactory.SomeEvent( someDateTime + _uut.LongBreak + _uut.LongBreak); _uut.Map(eventBeforeBreak); _uut.Map(droppedEvent); CollectionAssert.DoesNotContain(_uut.Map(eventAfterSecondLongBreak), droppedEvent); }
/// <inheritdoc /> public override DailyAnswer ToDailyAnswer(int year) { var calculationDay = DateTimeFactory.Create(year, 2, 1); calculationDay = OccurrenceHelper.FindOccurrenceOfDayOfWeek(calculationDay, DayOfWeek.Monday, 3); return(DailyAnswerBuilder .Create(Name, HolidayType) .From(calculationDay) .Country(Country.ToCode(), GetRegionCodeList()) .I18N(I18NIdentityCode) .Build(year)); }
public void TestCreateOverflow() { var factory = new DateTimeFactory { TimeZone = TimeZone }; var result = factory.CreateDateTimeOffset(2012, 12, 30, 24, 90, 100); Assert.AreEqual("2012-12-31T01:31:40-06:00", result.ToString(Format)); result = factory.CreateDateTimeOffset(2013, 1, 1, 0, 0, -30); Assert.AreEqual("2012-12-31T23:59:30-06:00", result.ToString(Format)); result = factory.CreateDateTimeOffset(2018, 1, 24, 36, 80, -1000000); Assert.AreEqual("2018-01-13T23:33:20-06:00", result.ToString(Format)); }
public void Edit() { var employer = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = new PersonBuilder(this.Session).WithLastName("employee").Build(); // Delete all existing for the new one to be in the first page of the list. foreach (PartyRelationship partyRelationship in employer.PartyRelationshipsWhereParty) { partyRelationship.Delete(); } this.Session.Derive(); this.Session.Commit(); var editPartyRelationship = new EmploymentBuilder(this.Session) .WithEmployee(employee) .WithEmployer(employer) .Build(); this.Session.Derive(); this.Session.Commit(); var before = new Employments(this.Session).Extent().ToArray(); this.organisationListPage.Table.DefaultAction(employer); var organisationOverview = new OrganisationOverviewComponent(this.organisationListPage.Driver); var partyRelationshipOverview = organisationOverview.PartyrelationshipOverviewPanel.Click(); partyRelationshipOverview.Table.DefaultAction(editPartyRelationship); var partyRelationshipEdit = new EmploymentEditComponent(organisationOverview.Driver); partyRelationshipEdit .FromDate.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ThroughDate.Set(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1)) .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new Employments(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, this.editPartyRelationship.FromDate.Date.ToUniversalTime().Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).AddYears(1).Date, this.editPartyRelationship.ThroughDate.Value.Date.ToUniversalTime().Date); Assert.Equal(employer, editPartyRelationship.Employer); Assert.Equal(employee, editPartyRelationship.Employee); }
public void Create() { var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = allors.ActiveEmployees.First; var before = new PhoneCommunications(this.Session).Extent().ToArray(); var extent = new Organisations(this.Session).Extent(); var organisation = extent.First(v => v.PartyName.Equals("Acme0")); var contact = organisation.CurrentContacts.First(v => v.FirstName.Equals("Jane0")); var organisationOverviewPage = this.organisations.Select(organisation); var page = organisationOverviewPage.NewPhoneCommunication(); page.LeftVoiceMail.Set(true) .EventState.Set(new CommunicationEventStates(this.Session).Completed.Name) .Purposes.Toggle(new CommunicationEventPurposes(this.Session).Inquiry.Name) .Subject.Set("subject") .FromParty.Set(contact.PartyName) .ToParty.Set(employee.PartyName) .PhoneNumber.Set("+1 123 456") .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .Comment.Set("comment") .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new PhoneCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var communicationEvent = after.Except(before).First(); Assert.True(communicationEvent.LeftVoiceMail); Assert.Equal(new CommunicationEventStates(this.Session).Completed, communicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Inquiry, communicationEvent.EventPurposes); Assert.Equal(contact, communicationEvent.FromParty); Assert.Equal(employee, communicationEvent.ToParty); Assert.Equal(contact.GeneralPhoneNumber, communicationEvent.PhoneNumber); Assert.Equal("subject", communicationEvent.Subject); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date); Assert.Equal("comment", communicationEvent.Comment); }
public void VerifyManyTypeAndShouldBeFailureTest() { var d = new Dictionary <string, object> { ["Name"] = "", ["Length"] = -1000L, ["Width"] = -30L, ["CreateTime"] = DateTimeFactory.Create(2020, 12, 21), ["Email"] = "nice@@boat.com" }; AnnotationValidator.VerifyMany(typeof(NiceBoat), d).IsValid.ShouldBeFalse(); AnnotationValidator.VerifyMany <NiceBoat>(d).IsValid.ShouldBeFalse(); }
public void Create() { var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = allors.ActiveEmployees.First; var before = new PhoneCommunications(this.Session).Extent().ToArray(); var person = new People(this.Session).Extent().First; this.people.Table.DefaultAction(person); var communicationEventOverview = new PersonOverviewComponent(this.people.Driver).CommunicationeventOverviewPanel.Click(); communicationEventOverview .CreatePhoneCommunication() .LeftVoiceMail.Set(true) .CommunicationEventState.Select(new CommunicationEventStates(this.Session).Completed) .EventPurposes.Toggle(new CommunicationEventPurposes(this.Session).Inquiry) .Subject.Set("subject") .FromParty.Select(person) .ToParty.Select(employee) .FromPhoneNumber.Select(person.GeneralPhoneNumber) .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .Comment.Set("comment") .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new PhoneCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var communicationEvent = after.Except(before).First(); Assert.True(communicationEvent.LeftVoiceMail); Assert.Equal(new CommunicationEventStates(this.Session).Completed, communicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Inquiry, communicationEvent.EventPurposes); Assert.Equal(person, communicationEvent.FromParty); Assert.Equal(employee, communicationEvent.ToParty); Assert.Equal(person.GeneralPhoneNumber, communicationEvent.PhoneNumber); Assert.Equal("subject", communicationEvent.Subject); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date); Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date); Assert.Equal("comment", communicationEvent.Comment); }
public void ConditionWithAndOr_WithAC_Complex_ShouldBeSuccess_Test() { var options = new ValidationOptions(); options.AnnotationEnabled = false; options.FailureIfInstanceIsNull = true; options.FailureIfProjectNotMatch = false; options.CustomValidatorEnabled = false; var provider = new ValidationProvider(ValidationProjectManager, VerifiableObjectResolver, options); ValidationRegistrar.ForProvider(provider, "UT_ConditionWithAndOr_WithAC_Complex_ShouldBeSuccess_Test") .ForType <NiceBoat>() .ForMember(x => x.Name) .MaxLength(8).When((o, v) => o.Width == 30 && v.StartsWith("M")).And().MinLength(6).When(x => x.StartsWith("M")) .Or().MinLength(7).Unless((o, v) => v.StartsWith("M") || o.Email == "*****@*****.**") .Or().Empty().When((o, v) => o.Length == 1000) .Build(); var validator = ValidationMe.Use("UT_ConditionWithAndOr_WithAC_Complex_ShouldBeSuccess_Test").Resolve <NiceBoat>(); var instance1 = new NiceBoat { Name = "NiceBoat1", //9 Length = 1001, Width = 30, CreateTime = DateTimeFactory.Create(2020, 12, 21), Email = "*****@*****.**" }; var instance2 = new NiceBoat { Name = "", //0 Length = 1000, Width = 30, CreateTime = DateTimeFactory.Create(2020, 12, 21), Email = "*****@*****.**" }; var result1 = validator.Verify(instance1); var result2 = validator.Verify(instance2); result1.ShouldNotBeNull(); result2.ShouldNotBeNull(); result1.IsValid.ShouldBeTrue(); result2.IsValid.ShouldBeTrue(); }
public void Edit() { var extent = new Organisations(this.Session).Extent(); var organisation = extent.First(v => v.PartyName.Equals("Acme0")); var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var firstEmployee = allors.ActiveEmployees.First(v => v.FirstName.Equals("first")); var before = new PhoneCommunications(this.Session).Extent().ToArray(); var personOverview = this.organisations.Select(organisation); var page = personOverview.SelectPhoneCommunication(this.editCommunicationEvent); page.LeftVoiceMail.Set(false) .EventState.Set(new CommunicationEventStates(this.Session).Completed.Name) .Purposes.Toggle(new CommunicationEventPurposes(this.Session).Inquiry.Name) .FromParty.Set(organisation.PartyName) .ToParty.Set(firstEmployee.PartyName) .PhoneNumber.Set("+1 111 222") .Subject.Set("new subject") .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 24)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 25)) .Comment.Set("new comment") .Save.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new PhoneCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length); Assert.False(this.editCommunicationEvent.LeftVoiceMail); Assert.Equal(new CommunicationEventStates(this.Session).Completed, this.editCommunicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Inquiry, this.editCommunicationEvent.EventPurposes); Assert.Equal(organisation, this.editCommunicationEvent.FromParty); Assert.Equal(firstEmployee, this.editCommunicationEvent.ToParty); Assert.Equal(this.organisationPhoneNumber.ContactMechanism, this.editCommunicationEvent.PhoneNumber); Assert.Equal("new subject", this.editCommunicationEvent.Subject); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ScheduledStart); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ScheduledEnd.Value.Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualStart.Value.Date); //Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 24).Date, communicationEvent.ActualEnd.Value.Date); Assert.Equal("new comment", this.editCommunicationEvent.Comment); }
public void ShouldCombineResultsForMultipleDeveloperStreams() { _uut.MaxEventsBeforeBreak = 2; var triggeredAt = DateTimeFactory.SomeWorkingHoursDateTime(); var firstEvent = new TestIDEEvent { TriggeredAt = triggeredAt }; var secondEvent = new CommandEvent { TriggeredAt = triggeredAt }; var lateEvent = new TestIDEEvent { TriggeredAt = triggeredAt + _uut.MinBreakTime }; var listOfEvents = new List<IDEEvent> { firstEvent, secondEvent, lateEvent }; _uut.OnStreamStarts(new Developer()); listOfEvents.ForEach(@event => _uut.OnEvent(@event)); _uut.OnStreamEnds(); _uut.OnStreamStarts(new Developer()); listOfEvents.ForEach(@event => _uut.OnEvent(@event)); _uut.OnStreamEnds(); var expectedStatistic = new Dictionary<string, Tuple<TimeSpan, int>> { { String.Format( "{0}{1}{2}", EventMappingUtils.GetAbstractStringOf(new TestIDEEvent()), AverageBreakAfterEventsCalculator.StatisticStringSeparator, EventMappingUtils.GetAbstractStringOf(new CommandEvent())), new Tuple<TimeSpan, int>(_uut.MinBreakTime, 2) } }; CollectionAssert.AreEquivalent(expectedStatistic, _uut.Statistic); }
/// <inheritdoc /> public override DailyAnswer ToDailyAnswer(int year) { var calculationDay = DateTimeFactory.Create(year, 5, 24); while (calculationDay.DayOfWeek != DayOfWeek.Monday) { calculationDay = calculationDay.AddDays(-1); } return(DailyAnswerBuilder .Create(Name, HolidayType) .From(calculationDay) .Country(Country.ToCode(), GetRegionCodeList()) .I18N(I18NIdentityCode) .Build(year)); }
/// <inheritdoc /> public override DailyAnswer ToDailyAnswer(int year) { var calculationDay = DateTimeFactory.Create(year, 1, 1); //当元旦为周末时,使用 Region 定义器来定义 if (WeekendManager.GetWeekendDictionary(CountryCode.GB).IsWeekend(calculationDay)) { return(DailyAnswerBuilder .Create(Name, HolidayType) .From(calculationDay) .Country(Country.ToCode(), GetRegionCodeList()) .I18N(I18NIdentityCode) .Build(year)); } return(null); }
public void ShouldAddUnknownTriggerMappingsToSeparateStatistic() { var eventTime = DateTimeFactory.SomeWorkingHoursDateTime(); var commandEvent1 = new CommandEvent { CommandId = "Test1", TriggeredAt = eventTime }; var commandEvent2 = new CommandEvent { CommandId = "Test2", TriggeredAt = eventTime + ConcurrentEventHeuristic.EventTimeDifference }; var commandEvent3 = new CommandEvent { CommandId = commandEvent1.CommandId, TriggeredAt = eventTime + ConcurrentEventHeuristic.EventTimeDifference + TimeSpan.FromSeconds(1) }; var commandEvent4 = new CommandEvent { CommandId = commandEvent2.CommandId, TriggeredAt = eventTime + ConcurrentEventHeuristic.EventTimeDifference + TimeSpan.FromSeconds(1) + ConcurrentEventHeuristic.EventTimeDifference }; _uut.OnStreamStarts(TestFactory.SomeDeveloper()); _uut.OnEvent(commandEvent1); _uut.OnEvent(commandEvent2); _uut.OnEvent(commandEvent3); _uut.OnEvent(commandEvent4); var expectedPair = SortedCommandPair.NewSortedPair(commandEvent1.CommandId, commandEvent2.CommandId); CollectionAssert.AreEquivalent( new Dictionary <SortedCommandPair, int> { { expectedPair, 2 } }, _uut.UnknownTriggerMappings); CollectionAssert.IsEmpty(_uut.Statistic); }
public void Create() { var allors = new Organisations(this.Session).FindBy(M.Organisation.Name, "Allors BVBA"); var employee = allors.ActiveEmployees.First; var before = new FaceToFaceCommunications(this.Session).Extent().ToArray(); var organisation = allors.ActiveCustomers.First(v => v.GetType().Name == typeof(Organisation).Name); var contact = organisation.CurrentContacts.First; this.organisationListPage.Table.DefaultAction(organisation); var faceToFaceCommunicationEdit = new OrganisationOverviewComponent(this.organisationListPage.Driver).CommunicationeventOverviewPanel.Click().CreateFaceToFaceCommunication(); faceToFaceCommunicationEdit .CommunicationEventState.Select(new CommunicationEventStates(this.Session).Completed) .EventPurposes.Toggle(new CommunicationEventPurposes(this.Session).Appointment) .Location.Set("location") .Subject.Set("subject") .FromParty.Select(employee) .ToParty.Select(contact) .ScheduledStart.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ScheduledEnd.Set(DateTimeFactory.CreateDate(2018, 12, 22)) .ActualStart.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .ActualEnd.Set(DateTimeFactory.CreateDate(2018, 12, 23)) .SAVE.Click(); this.Driver.WaitForAngular(); this.Session.Rollback(); var after = new FaceToFaceCommunications(this.Session).Extent().ToArray(); Assert.Equal(after.Length, before.Length + 1); var communicationEvent = after.Except(before).First(); Assert.Equal(new CommunicationEventStates(this.Session).Completed, communicationEvent.CommunicationEventState); Assert.Contains(new CommunicationEventPurposes(this.Session).Appointment, communicationEvent.EventPurposes); Assert.Equal(employee, communicationEvent.FromParty); Assert.Equal(contact, communicationEvent.ToParty); Assert.Equal("location", communicationEvent.Location); Assert.Equal("subject", communicationEvent.Subject); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledStart.Value.ToUniversalTime().Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 22).Date, communicationEvent.ScheduledEnd.Value.Date.ToUniversalTime().Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualStart.Value.Date.ToUniversalTime().Date); // Assert.Equal(DateTimeFactory.CreateDate(2018, 12, 23).Date, communicationEvent.ActualEnd.Value.Date.ToUniversalTime().Date); }
/// <summary> /// Match date.<br /> /// 匹配日期 /// </summary> /// <param name="year"></param> /// <param name="month"></param> /// <param name="day"></param> /// <returns></returns> public bool Match(int year, int month, int day) { if (!Match(year)) { return(false); } var dt = DateTimeFactory.Create(year, month, day); // ReSharper disable once ConvertIfStatementToReturnStatement if (dt < FromDate.ToDateTime() || dt > ToDate.ToDateTime()) { return(false); } return(true); }