public async Task Handle_RaisesException_WhenOrganizationUserExists() { var username = DataProvider.Get <string>(); var role = DataProvider.Get <string>(); DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var org = new OrganizationBuilder().BuildAndPersist(s); new TestObjectBuilder <OrganizationUser>() .SetArgument(o => o.Username, username) .SetArgument(o => o.Role, role) .SetArgument(o => o.Organization, org) .BuildAndPersist(s); return(new { Cmd = new CreateOrganizationUserCommand(username, role, org) }); }); await Endpoint.ActRaisesException <CreateOrganizationUserCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => h.Handle(testParams.Cmd, ctx)); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var organizationUser = s.Query <OrganizationUser>().Single(); organizationUser.Should().NotBeNull(); }); }
public async Task Handle_RaisesException_WhenInvalidOrganization() { var username = DataProvider.Get <string>(); var role = DataProvider.Get <string>(); DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var org = new OrganizationBuilder().Build(); //not persisted return(new { Cmd = new CreateOrganizationUserCommand(username, role, org) }); }); await Endpoint.ActRaisesException <CreateOrganizationUserCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => h.Handle(testParams.Cmd, ctx)); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var organizationUser = s.Query <OrganizationUser>().SingleOrDefault(); organizationUser.Should().BeNull(); }); }
public async Task Handle_DeletesOrganization() { var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var organization = new OrganizationBuilder().BuildAndPersist(s); return(new { username, cmd = new DeleteOrganizationCommand(organization.Id) }); }); await Endpoint.Act <DeleteOrganizationCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.cmd, ctx)); }); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var organization = s.Get <Organization>(testParams.cmd.OrganizationId); organization.Should().BeNull(); }); }
public async Task Handle_SavesUnitReport(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, OrganizationType.Unit) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); var cmd = new CreateUnitPlanCommand(organization, year, reportingTerm, reportingFrequency); var description = cmd.Description; var expected = new UnitReportBuilder() .SetDescription(description) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .SetReportData(ReportData.Default()) .Build(); return(new { cmd, username, expected }); }); var context = await Endpoint.Act <CreateUnitPlanCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.cmd, ctx)); }); var evt = context.ExpectPublish <IUnitPlanCreated>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var report = s.Query <UnitReport>().Single(); report.Should().NotBeNull(); report.Should().BeEquivalentTo(testParams.expected, e => e.Excluding(p => p.Id)); report.ReportingPeriod.Should().BeEquivalentTo(testParams.expected.ReportingPeriod); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <IUnitPlanCreated>(e => { e.Organization = testParams.expected.Organization; e.Username = testParams.username; e.UnitReport = reportRef; }); evt.Should().BeEquivalentTo(expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_DeletesReport(OrganizationType organizationType, ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new OrganizationBuilder() .SetOrganizationType(organizationType) .SetReportingFreQuency(reportingFrequency) .BuildAndPersist(s); Report report = new ReportBuilder() .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .BuildAndPersist(s); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <IReportDeleted>(e => { e.Organization = organization; e.Username = username; e.Report = reportRef; }); return(new { Cmd = new DeleteReportCommand(report.Id), username, expectedEvt }); }); var context = await Endpoint.Act <DeleteReportCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IReportDeleted>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var report = s.Get <Report>(testParams.Cmd.ReportId); report.Should().BeNull(); evt.Should().BeEquivalentTo(testParams.expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_DoNotSavesCentralReport_WhenDuplicate(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var description = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, OrganizationType.Central) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); var copyFrom = new CentralReportBuilder() .SetDescription(description) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year - 1)) .BuildAndPersist(s); var duplicate = new CentralReportBuilder() .SetDescription(description) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .BuildAndPersist(s); return(new { Cmd = new CopyCentralPlanCommand(copyFrom.Id, organization, year, reportingTerm, reportingFrequency), username, duplicate }); }); var context = await Endpoint.Act <CopyCentralPlanCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <ICentralPlanCopyFailed>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var report = s.Query <CentralReport>().OrderByDescending(o => o.Id).First(); report.Should().NotBeNull(); report.Should().BeEquivalentTo(testParams.duplicate); evt.Errors[0].Should().Contain(testParams.duplicate.Description); }); }
public async Task Handle_SavesRecord(OrganizationType organizationType, ReportingFrequency reportingFrequency) { var username = DataProvider.Get <string>(); var description = DataProvider.Get <string>(); var details = DataProvider.Get <string>(); var parent = DataProvider.Get <EntityReference>(); DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var expected = new OrganizationBuilder() .SetDescription(description) .SetDetails(details) .SetParent(parent) .SetOrganizationType(organizationType) .SetReportingFreQuency(reportingFrequency) .Build(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => new { Cmd = new CreateOrganizationCommand(description, details, organizationType, reportingFrequency, parent), username, expected }); var context = await Endpoint.Act <CreateOrganizationCommandHandler>( AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IOrganizationCreated>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var org = s.Query <Organization>().Single(); org.Should().NotBeNull(); org.Should().BeEquivalentTo(testParams.expected, e => e.Excluding(p => p.Id)); OrganizationReference orgRef = org; var expectedEvt = Test.CreateInstance <IOrganizationCreated>(e => { e.Organization = orgRef; e.Username = testParams.username; }); evt.Should().BeEquivalentTo(expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_RaisesFailedEvent_WhenParentIsSameOrganization(OrganizationType newOrganizationType, ReportingFrequency newReportingFrequency) { var now = DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var username = DataProvider.Get <string>(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var org = new OrganizationBuilder().BuildAndPersist(s); EntityReference parent = org; var newDescription = DataProvider.Get <string>(); var newDetails = DataProvider.Get <string>(); var expectedEvt = Test.CreateInstance <IOrganizationUpdateFailed>(e => { e.Errors = new string[] { $"unable to add same organization as Parent organization" }; }); return(new { username, expectedEvt, Cmd = new UpdateOrganizationCommand(org.Id, newDescription, newDetails, newOrganizationType, newReportingFrequency, parent), org }); }); var context = await Endpoint.Act <UpdateOrganizationCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IOrganizationUpdateFailed>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var organization = s.Query <Organization>().SingleOrDefault(); organization.Should().NotBeNull(); organization.Should().BeEquivalentTo(testParams.org); }); evt.Should().BeEquivalentTo(testParams.expectedEvt); }
protected void TestInsertAndRetrieve(Func <T> creator = null) { var aggregate = Endpoint.ActOnSqlSession(ExecutionContainer, session => { var item = creator != null ? creator() : CreateAggregate(); session.Save(item); return(item); }); Endpoint.AssertOnSqlSessionThat(ExecutionContainer, s => { var retrievedAggregate = s.Get <T>(aggregate.Id); retrievedAggregate.Should().BeEquivalentTo(aggregate, Options); }); }
public async Task Handle_SavesRecord() { var username = DataProvider.Get <string>(); var role = DataProvider.Get <string>(); var now = DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var org = new OrganizationBuilder().BuildAndPersist(s); return(new { username, Cmd = new CreateOrganizationUserCommand(username, role, org) }); }); await Endpoint.Act <CreateOrganizationUserCommandHandler>( AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var organizationUser = s.Query <OrganizationUser>().Single(); organizationUser.Should().NotBeNull(); organizationUser.Username.Should().Be(testParams.Cmd.Username); organizationUser.Role.Should().Be(testParams.Cmd.Role); organizationUser.Organization.Should().Be(testParams.Cmd.Organization); organizationUser.Timestamp.Should().Be(now); organizationUser.IsDeleted.Should().Be(false); }); }
public async Task Handle_DeletesOrganizationUser() { var deletedByusername = DataProvider.Get <string>(); var username = DataProvider.Get <string>(); var role = DataProvider.Get <string>(); DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var org = new OrganizationBuilder().BuildAndPersist(s); var organizationUser = new TestObjectBuilder <OrganizationUser>() .SetArgument(o => o.Username, username) .SetArgument(o => o.Role, role) .SetArgument(o => o.Organization, org) .BuildAndPersist(s); return(new { deletedByusername, cmd = new DeleteOrganizationUserCommand(organizationUser.Id) }); }); await Endpoint.Act <DeleteOrganizationUserCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.deletedByusername); return(h.Handle(testParams.cmd, ctx)); }); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var report = s.Get <OrganizationUser>(testParams.cmd.OrganizationUserId); report.Should().BeNull(); }); }
public async Task Handle_UnitPlanCreated(ReportingFrequency reportingFrequency) { var now = DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, OrganizationType.Unit) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); var evt = Test.CreateInstance <IUnitPlanCreated>(x => { x.Username = username; x.Organization = organization; x.UnitReport = DataProvider.Get <EntityReference>(); x.SerializedData = DataProvider.Get <string>(); }); return(new { evt }); }); await Endpoint.Act <LogWhenReportEventReceived>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => h.Handle(testParams.evt, ctx)); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var reportEventLog = s.Query <ReportEventLog>().Single(); reportEventLog.Should().NotBeNull(); reportEventLog.OrganizationId.Should().Be(testParams.evt.Organization.Id); reportEventLog.Timestamp.Should().Be(now); }); }
public async Task Handle_SavesPlan(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new OrganizationBuilder() .SetOrganizationType(OrganizationType.Unit) .SetReportingFreQuency(reportingFrequency) .BuildAndPersist(s); var report = new UnitReportBuilder() .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .BuildAndPersist(s); var associateMemberData = new TestObjectBuilder <MemberData>() .Build(); var preliminaryMemberData = new TestObjectBuilder <MemberData>() .Build(); var workerMeetingProgramData = new TestObjectBuilder <MeetingProgramData>() .Build(); var supporterMemberData = new TestObjectBuilder <MemberData>() .Build(); var memberMemberData = new TestObjectBuilder <MemberData>() .Build(); PlanData planData = new ReportDataBuilder() .SetAssociateMemberData(associateMemberData) .SetPreliminaryMemberData(preliminaryMemberData) .SetWorkerMeetingProgramData(workerMeetingProgramData) .SetSupporterMemberData(supporterMemberData) .SetMemberMemberData(memberMemberData) .Build(); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <IUnitPlanUpdated>(e => { e.Organization = organization; e.Username = username; e.UnitReport = reportRef; }); return(new { Cmd = new UpdateUnitPlanCommand(report.Id, planData), Organization = organization, Report = report, username, expectedEvt }); }); var context = await Endpoint.Act <UpdateUnitPlanCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IUnitPlanUpdated>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var unitReport = s.Get <UnitReport>(testParams.Cmd.ReportId); unitReport.Should().NotBeNull(); unitReport.Should().BeEquivalentTo(testParams.Report, e => e.Excluding(p => p.AssociateMemberData) .Excluding(p => p.PreliminaryMemberData) .Excluding(p => p.SupporterMemberData) .Excluding(p => p.WorkerMeetingProgramData) .Excluding(p => p.DawahMeetingProgramData) .Excluding(p => p.StateLeaderMeetingProgramData) .Excluding(p => p.StateOutingMeetingProgramData) .Excluding(p => p.IftarMeetingProgramData) .Excluding(p => p.LearningMeetingProgramData) .Excluding(p => p.SocialDawahMeetingProgramData) .Excluding(p => p.DawahGroupMeetingProgramData) .Excluding(p => p.NextGMeetingProgramData) .Excluding(p => p.CmsMeetingProgramData) .Excluding(p => p.SmMeetingProgramData) .Excluding(p => p.MemberMeetingProgramData) .Excluding(p => p.TafsirMeetingProgramData) .Excluding(p => p.UnitMeetingProgramData) .Excluding(p => p.FamilyVisitMeetingProgramData) .Excluding(p => p.EidReunionMeetingProgramData) .Excluding(p => p.BbqMeetingProgramData) .Excluding(p => p.GatheringMeetingProgramData) .Excluding(p => p.OtherMeetingProgramData) .Excluding(p => p.MemberMemberData) .Excluding(p => p.BaitulMalFinanceData) .Excluding(p => p.ADayMasjidProjectFinanceData) .Excluding(p => p.MasjidTableBankFinanceData) .Excluding(p => p.QardeHasanaSocialWelfareData) .Excluding(p => p.PatientVisitSocialWelfareData) .Excluding(p => p.SocialVisitSocialWelfareData) .Excluding(p => p.TransportSocialWelfareData) .Excluding(p => p.ShiftingSocialWelfareData) .Excluding(p => p.ShoppingSocialWelfareData) .Excluding(p => p.FoodDistributionSocialWelfareData) .Excluding(p => p.CleanUpAustraliaSocialWelfareData) .Excluding(p => p.OtherSocialWelfareData) .Excluding(p => p.BookSaleMaterialData) .Excluding(p => p.BookDistributionMaterialData) .Excluding(p => p.BookLibraryStockData) .Excluding(p => p.OtherSaleMaterialData) .Excluding(p => p.OtherDistributionMaterialData) .Excluding(p => p.OtherLibraryStockData) .Excluding(p => p.VhsSaleMaterialData) .Excluding(p => p.VhsDistributionMaterialData) .Excluding(p => p.VhsLibraryStockData) .Excluding(p => p.EmailDistributionMaterialData) .Excluding(p => p.IpdcLeafletDistributionMaterialData) .Excluding(p => p.GroupStudyTeachingLearningProgramData) .Excluding(p => p.StudyCircleTeachingLearningProgramData) .Excluding(p => p.PracticeDarsTeachingLearningProgramData) .Excluding(p => p.StateLearningCampTeachingLearningProgramData) .Excluding(p => p.QuranStudyTeachingLearningProgramData) .Excluding(p => p.QuranClassTeachingLearningProgramData) .Excluding(p => p.MemorizingAyatTeachingLearningProgramData) .Excluding(p => p.StateLearningSessionTeachingLearningProgramData) .Excluding(p => p.StateQiyamulLailTeachingLearningProgramData) // .Excluding(p => p.StudyCircleForAssociateMemberTeachingLearningProgramData) .Excluding(p => p.HadithTeachingLearningProgramData) .Excluding(p => p.WeekendIslamicSchoolTeachingLearningProgramData) .Excluding(p => p.MemorizingHadithTeachingLearningProgramData) .Excluding(p => p.MemorizingDoaTeachingLearningProgramData) .Excluding(p => p.OtherTeachingLearningProgramData) ); ReportData reportData = unitReport; PlanData planData = reportData; planData.Should().BeEquivalentTo(testParams.Cmd.PlanData); evt.Should().BeEquivalentTo(testParams.expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_SavesReportWhenNoPreviousReportSubmitted(ReportingFrequency reportingFrequency, bool overrideReportData) { var now = DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new OrganizationBuilder() .SetOrganizationType(OrganizationType.Zone) .SetReportingFreQuency(reportingFrequency) .BuildAndPersist(s); var report = new ZoneReportBuilder() .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .Build(); report.MarkStatusAsPlanPromoted(); s.Save(report); var generatedData = GetZoneReportData(); report.UpdateGeneratedData(generatedData); report.Update(generatedData); s.Save(report); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <IZoneReportUpdated>(e => { e.Organization = organization; e.Username = username; e.ZoneReport = reportRef; }); return(new { Cmd = new UpdateZoneReportGeneratedDataCommand(report.Id, overrideReportData), Organization = organization, Report = report, zoneReportData = generatedData, overrideReportData, username, expectedEvt }); }); var context = await Endpoint.Act <UpdateZoneReportGeneratedDataCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IZoneReportUpdated>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var report = s.Get <Report>(testParams.Cmd.ReportId); report.Should().NotBeNull(); report.Description.Should().Be(testParams.Report.Description); report.ReportingPeriod.Year.Should().Be(testParams.Report.ReportingPeriod.Year); report.ReportingPeriod.ReportingFrequency.Should().Be(testParams.Organization.ReportingFrequency); report.ReportingPeriod.ReportingTerm.Should().Be(testParams.Report.ReportingPeriod.ReportingTerm); report.Organization.Should().Be(testParams.Report.Organization); report.ReportStatus.Should().Be(ReportStatus.PlanPromoted); report.Timestamp.Should().Be(now); report.IsDeleted.Should().Be(false); var zoneReport = s.Get <ZoneReport>(testParams.Cmd.ReportId); zoneReport.Should().NotBeNull(); zoneReport.Description.Should().Be(testParams.Report.Description); zoneReport.ReportingPeriod.Year.Should().Be(testParams.Report.ReportingPeriod.Year); zoneReport.ReportingPeriod.ReportingFrequency.Should() .Be(testParams.Organization.ReportingFrequency); zoneReport.ReportingPeriod.ReportingTerm.Should() .Be(testParams.Report.ReportingPeriod.ReportingTerm); zoneReport.Organization.Should().Be(testParams.Report.Organization); //zoneReport.AssociateMemberData.Should().Be(overrideReportData // ? MemberData.Default() // : testParams.zoneReportData.AssociateMemberData); //zoneReport.AssociateMemberGeneratedData.Should().Be(MemberData.Default()); //zoneReport.PreliminaryMemberData.Should().Be(overrideReportData // ? MemberData.Default() // : testParams.zoneReportData.PreliminaryMemberData); //zoneReport.PreliminaryMemberGeneratedData.Should().Be(MemberData.Default()); //zoneReport.WorkerMeetingProgramData.Should().Be(overrideReportData // ? MeetingProgramData.Default() // : testParams.zoneReportData.WorkerMeetingProgramData); //zoneReport.WorkerMeetingProgramGeneratedData.Should().Be(MeetingProgramData.Default()); zoneReport.Timestamp.Should().Be(now); zoneReport.IsDeleted.Should().Be(false); evt.Should().BeEquivalentTo(testParams.expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_SavesReport(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new OrganizationBuilder() .SetOrganizationType(OrganizationType.Central) .SetReportingFreQuency(reportingFrequency) .BuildAndPersist(s); var report = new CentralReportBuilder() .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .Build(); report.MarkStatusAsPlanPromoted(); s.Save(report); var memberMemberData = new TestObjectBuilder <MemberData>() .Build(); var associateMemberData = new TestObjectBuilder <MemberData>() .Build(); var preliminaryMemberData = new TestObjectBuilder <MemberData>() .Build(); //Todo pass random data once supporterMember is added to the CentralReport var supporterMemberData = new TestObjectBuilder <MemberData>() .Build(); var workerMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var dawahMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var stateLeaderMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var stateOutingMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var iftarMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var learningMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var socialDawahMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var dawahGroupMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var nextGMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var cmsMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var smMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var memberMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var tafsirMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var unitMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var familyVisitMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var eidReunionMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var bbqMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var gatheringMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var otherMeetingProgramData = new TestObjectBuilder <MeetingProgramData>().Build(); var groupStudyTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var studyCircleTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var practiceDarsTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var stateLearningCampTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var quranStudyTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var quranClassTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var memorizingAyatTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var stateLearningSessionTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var stateQiyamulLailTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var studyCircleForAssociateMemberTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var hadithTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var weekendIslamicSchoolTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var memorizingHadithTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var memorizingDoaTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var otherTeachingLearningProgramData = new TestObjectBuilder <TeachingLearningProgramData>().Build(); var baitulMalFinanceData = FinanceData.Default(); var aDayMasjidProjectFinanceData = FinanceData.Default(); var masjidTableBankFinanceData = FinanceData.Default(); var qardeHasanaSocialWelfareData = SocialWelfareData.Default(); var patientVisitSocialWelfareData = SocialWelfareData.Default(); var socialVisitSocialWelfareData = SocialWelfareData.Default(); var transportSocialWelfareData = SocialWelfareData.Default(); var shiftingSocialWelfareData = SocialWelfareData.Default(); var shoppingSocialWelfareData = SocialWelfareData.Default(); var foodDistributionSocialWelfareData = SocialWelfareData.Default(); var cleanUpAustraliaSocialWelfareData = SocialWelfareData.Default(); var otherSocialWelfareData = SocialWelfareData.Default(); var bookSaleMaterialData = MaterialData.Default(); var bookDistributionMaterialData = MaterialData.Default(); var bookLibraryStockData = LibraryStockData.Default(); var otherSaleMaterialData = MaterialData.Default(); var otherDistributionMaterialData = MaterialData.Default(); var otherLibraryStockData = LibraryStockData.Default(); var vhsSaleMaterialData = MaterialData.Default(); var vhsDistributionMaterialData = MaterialData.Default(); var vhsLibraryStockData = LibraryStockData.Default(); var emailDistributionMaterialData = MaterialData.Default(); var ipdcLeafletDistributionMaterialData = MaterialData.Default(); //var bookLibraryStockData = LibraryStockData.Default(); //var vhsLibraryStockData = LibraryStockData.Default(); var comment = DataProvider.Get <string>(); ReportUpdateData centralReportUpdateData = new ReportDataBuilder() .SetMemberMemberData(memberMemberData) .SetAssociateMemberData(associateMemberData) .SetPreliminaryMemberData(preliminaryMemberData) .SetSupporterMemberData(supporterMemberData) .SetWorkerMeetingProgramData(workerMeetingProgramData) .SetDawahMeetingProgramData(dawahMeetingProgramData) .SetStateLeaderMeetingProgramData(stateLeaderMeetingProgramData) .SetStateOutingMeetingProgramData(stateOutingMeetingProgramData) .SetIftarMeetingProgramData(iftarMeetingProgramData) .SetLearningMeetingProgramData(learningMeetingProgramData) .SetSocialDawahMeetingProgramData(socialDawahMeetingProgramData) .SetDawahGroupMeetingProgramData(dawahGroupMeetingProgramData) .SetNextGMeetingProgramData(nextGMeetingProgramData) .SetCmsMeetingProgramData(cmsMeetingProgramData) .SetSmMeetingProgramData(smMeetingProgramData) .SetMemberMeetingProgramData(memberMeetingProgramData) .SetTafsirMeetingProgramData(tafsirMeetingProgramData) .SetUnitMeetingProgramData(unitMeetingProgramData) .SetFamilyVisitMeetingProgramData(familyVisitMeetingProgramData) .SetEidReunionMeetingProgramData(eidReunionMeetingProgramData) .SetBbqMeetingProgramData(bbqMeetingProgramData) .SetGatheringMeetingProgramData(gatheringMeetingProgramData) .SetOtherMeetingProgramData(otherMeetingProgramData) .SetGroupStudyTeachingLearningProgramData(groupStudyTeachingLearningProgramData) .SetStudyCircleTeachingLearningProgramData(studyCircleTeachingLearningProgramData) .SetPracticeDarsTeachingLearningProgramData(practiceDarsTeachingLearningProgramData) .SetStateLearningCampTeachingLearningProgramData(stateLearningCampTeachingLearningProgramData) .SetQuranStudyTeachingLearningProgramData(quranStudyTeachingLearningProgramData) .SetQuranClassTeachingLearningProgramData(quranClassTeachingLearningProgramData) .SetMemorizingAyatTeachingLearningProgramData(memorizingAyatTeachingLearningProgramData) .SetStateLearningSessionTeachingLearningProgramData(stateLearningSessionTeachingLearningProgramData) .SetStateQiyamulLailTeachingLearningProgramData(stateQiyamulLailTeachingLearningProgramData) .SetBaitulMalFinanceData(baitulMalFinanceData) .SetADayMasjidProjectFinanceData(aDayMasjidProjectFinanceData) .SetMasjidTableBankFinanceData(masjidTableBankFinanceData) .SetQardeHasanaSocialWelfareData(qardeHasanaSocialWelfareData) .SetPatientVisitSocialWelfareData(patientVisitSocialWelfareData) .SetSocialVisitSocialWelfareData(socialVisitSocialWelfareData) .SetTransportSocialWelfareData(transportSocialWelfareData) .SetShiftingSocialWelfareData(shiftingSocialWelfareData) .SetShoppingSocialWelfareData(shoppingSocialWelfareData) .SetFoodDistributionSocialWelfareData(foodDistributionSocialWelfareData) .SetCleanUpAustraliaSocialWelfareData(cleanUpAustraliaSocialWelfareData) .SetOtherSocialWelfareData(otherSocialWelfareData) .SetBookSaleMaterialData(bookSaleMaterialData) .SetBookDistributionMaterialData(bookDistributionMaterialData) .SetBookLibraryStockData(bookLibraryStockData) .SetOtherSaleMaterialData(otherSaleMaterialData) .SetOtherDistributionMaterialData(otherDistributionMaterialData) .SetOtherLibraryStockData(otherLibraryStockData) .SetVhsSaleMaterialData(vhsSaleMaterialData) .SetVhsDistributionMaterialData(vhsDistributionMaterialData) .SetVhsLibraryStockData(vhsLibraryStockData) .SetEmailDistributionMaterialData(emailDistributionMaterialData) .SetIpdcLeafletDistributionMaterialData(ipdcLeafletDistributionMaterialData) .SetGroupStudyTeachingLearningProgramData(groupStudyTeachingLearningProgramData) .SetStudyCircleTeachingLearningProgramData(studyCircleTeachingLearningProgramData) .SetPracticeDarsTeachingLearningProgramData(practiceDarsTeachingLearningProgramData) .SetStateLearningCampTeachingLearningProgramData(stateLearningCampTeachingLearningProgramData) .SetQuranStudyTeachingLearningProgramData(quranStudyTeachingLearningProgramData) .SetQuranClassTeachingLearningProgramData(quranClassTeachingLearningProgramData) .SetMemorizingAyatTeachingLearningProgramData(memorizingAyatTeachingLearningProgramData) .SetStateLearningSessionTeachingLearningProgramData(stateLearningSessionTeachingLearningProgramData) .SetStateQiyamulLailTeachingLearningProgramData(stateQiyamulLailTeachingLearningProgramData) .SetStudyCircleForAssociateMemberTeachingLearningProgramData(studyCircleForAssociateMemberTeachingLearningProgramData) .SetHadithTeachingLearningProgramData(hadithTeachingLearningProgramData) .SetWeekendIslamicSchoolTeachingLearningProgramData(weekendIslamicSchoolTeachingLearningProgramData) .SetMemorizingHadithTeachingLearningProgramData(memorizingHadithTeachingLearningProgramData) .SetMemorizingDoaTeachingLearningProgramData(memorizingDoaTeachingLearningProgramData) .SetOtherTeachingLearningProgramData(otherTeachingLearningProgramData) .SetComment(comment) .Build(); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <ICentralReportUpdated>(e => { e.Organization = organization; e.Username = username; e.CentralReport = reportRef; }); return(new { Cmd = new UpdateCentralReportCommand(report.Id, centralReportUpdateData), Report = report, username, expectedEvt }); }); var context = await Endpoint.Act <UpdateCentralReportCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <ICentralReportUpdated>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var centralReport = s.Get <CentralReport>(testParams.Cmd.ReportId); centralReport.Should().NotBeNull(); centralReport.Should().BeEquivalentTo(testParams.Report, e => e.Excluding(p => p.MemberMemberData) .Excluding(p => p.AssociateMemberData) .Excluding(p => p.PreliminaryMemberData) .Excluding(p => p.SupporterMemberData) .Excluding(p => p.WorkerMeetingProgramData) .Excluding(p => p.DawahMeetingProgramData) .Excluding(p => p.StateLeaderMeetingProgramData) .Excluding(p => p.StateOutingMeetingProgramData) .Excluding(p => p.IftarMeetingProgramData) .Excluding(p => p.LearningMeetingProgramData) .Excluding(p => p.SocialDawahMeetingProgramData) .Excluding(p => p.DawahGroupMeetingProgramData) .Excluding(p => p.NextGMeetingProgramData) .Excluding(p => p.CmsMeetingProgramData) .Excluding(p => p.SmMeetingProgramData) .Excluding(p => p.MemberMeetingProgramData) .Excluding(p => p.TafsirMeetingProgramData) .Excluding(p => p.UnitMeetingProgramData) .Excluding(p => p.FamilyVisitMeetingProgramData) .Excluding(p => p.EidReunionMeetingProgramData) .Excluding(p => p.BbqMeetingProgramData) .Excluding(p => p.GatheringMeetingProgramData) .Excluding(p => p.OtherMeetingProgramData) .Excluding(p => p.GroupStudyTeachingLearningProgramData) .Excluding(p => p.StudyCircleTeachingLearningProgramData) .Excluding(p => p.PracticeDarsTeachingLearningProgramData) .Excluding(p => p.StateLearningCampTeachingLearningProgramData) .Excluding(p => p.QuranStudyTeachingLearningProgramData) .Excluding(p => p.QuranClassTeachingLearningProgramData) .Excluding(p => p.MemorizingAyatTeachingLearningProgramData) .Excluding(p => p.StateLearningSessionTeachingLearningProgramData) .Excluding(p => p.StateQiyamulLailTeachingLearningProgramData) .Excluding(p => p.StudyCircleForAssociateMemberTeachingLearningProgramData) .Excluding(p => p.HadithTeachingLearningProgramData) .Excluding(p => p.WeekendIslamicSchoolTeachingLearningProgramData) .Excluding(p => p.MemorizingHadithTeachingLearningProgramData) .Excluding(p => p.MemorizingDoaTeachingLearningProgramData) .Excluding(p => p.OtherTeachingLearningProgramData) .Excluding(p => p.BookSaleMaterialData) .Excluding(p => p.BookDistributionMaterialData) .Excluding(p => p.BookLibraryStockData) .Excluding(p => p.OtherSaleMaterialData) .Excluding(p => p.OtherDistributionMaterialData) .Excluding(p => p.OtherLibraryStockData) .Excluding(p => p.VhsSaleMaterialData) .Excluding(p => p.VhsDistributionMaterialData) .Excluding(p => p.VhsLibraryStockData) .Excluding(p => p.EmailDistributionMaterialData) .Excluding(p => p.IpdcLeafletDistributionMaterialData) .Excluding(p => p.BaitulMalFinanceData) .Excluding(p => p.ADayMasjidProjectFinanceData) .Excluding(p => p.MasjidTableBankFinanceData) .Excluding(p => p.QardeHasanaSocialWelfareData) .Excluding(p => p.PatientVisitSocialWelfareData) .Excluding(p => p.SocialVisitSocialWelfareData) .Excluding(p => p.TransportSocialWelfareData) .Excluding(p => p.ShiftingSocialWelfareData) .Excluding(p => p.ShoppingSocialWelfareData) .Excluding(p => p.FoodDistributionSocialWelfareData) .Excluding(p => p.CleanUpAustraliaSocialWelfareData) .Excluding(p => p.OtherSocialWelfareData) .Excluding(p => p.Comment) ); ReportData reportData = centralReport; ReportUpdateData reportUpdateData = reportData; reportUpdateData.Should().BeEquivalentTo(testParams.Cmd.ReportUpdateData); evt.Should().BeEquivalentTo(testParams.expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_SavesPlan(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new OrganizationBuilder() .SetOrganizationType(OrganizationType.State) .SetReportingFreQuency(reportingFrequency) .BuildAndPersist(s); var associateMemberData = new TestObjectBuilder <MemberData>() .Build(); var preliminaryMemberData = new TestObjectBuilder <MemberData>() .Build(); PlanData planData = new ReportDataBuilder() .SetAssociateMemberData(associateMemberData) .SetPreliminaryMemberData(preliminaryMemberData) .Build(); var report = new StateReportBuilder() .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .BuildAndPersist(s); report.UpdatePlan(planData); s.Save(report); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <IStatePlanPromoted>(e => { e.Organization = organization; e.Username = username; e.StateReport = reportRef; }); return(new { Cmd = new PromotePlanToStateReportCommand(report.Id), Report = report, username, expectedEvt }); }); var context = await Endpoint.Act <PromotePlanToStateReportCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IStatePlanPromoted>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var stateReport = s.Get <StateReport>(testParams.Cmd.PlanId); stateReport.Should().NotBeNull(); stateReport.Should().BeEquivalentTo(testParams.Report, e => e.Excluding(p => p.ReportStatus)); stateReport.ReportStatus.Should().Be(ReportStatus.PlanPromoted); evt.Should().BeEquivalentTo(testParams.expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_SavesZoneReport(ReportingFrequency reportingFrequency, ReportingFrequency differentFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, OrganizationType.Zone) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); var existing = new ZoneReportBuilder() .SetDescription(DataProvider.Get <string>()) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .BuildAndPersist(s); var newReportYear = year + 1; new ZoneReportBuilder() .SetDescription(DataProvider.Get <string>()) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(differentFrequency, reportingTerm, newReportYear)) .BuildAndPersist(s); var cmd = new CopyZonePlanCommand(existing.Id, organization, newReportYear, reportingTerm, reportingFrequency); var description = cmd.Description; var lastPeriodData = Calculator.GetLastPeriodUpdateData(existing); var expected = new ZoneReportBuilder() .SetDescription(description) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, newReportYear)) .SetReportData(existing) .Build(); expected.Update(lastPeriodData); return(new { cmd, username, expected }); }); var context = await Endpoint.Act <CopyZonePlanCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.cmd, ctx)); }); var evt = context.ExpectPublish <IZonePlanCopied>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var report = s.Query <ZoneReport>().OrderByDescending(o => o.Id).First(); report.Should().NotBeNull(); report.Should().BeEquivalentTo(testParams.expected, e => e.Excluding(p => p.Id) .Excluding(p => p.ReportingPeriod) .Excluding(p => p.ReportStatus)); EntityReference reportRef = report; var expectedEvt = Test.CreateInstance <IZonePlanCopied>(e => { e.Organization = testParams.expected.Organization; e.Username = testParams.username; e.ZoneReport = reportRef; }); evt.Should().BeEquivalentTo(expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }); }
public async Task Handle_SavesRecord(OrganizationType newOrganizationType, ReportingFrequency newReportingFrequency) { var now = DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var username = DataProvider.Get <string>(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var org = new OrganizationBuilder().BuildAndPersist(s); EntityReference parent; switch (newOrganizationType) { case OrganizationType.State: parent = new OrganizationBuilder().SetOrganizationType(OrganizationType.Central).BuildAndPersist(s); break; case OrganizationType.Zone: case OrganizationType.Unit: parent = new OrganizationBuilder().SetOrganizationType(OrganizationType.State).BuildAndPersist(s); break; default: parent = new OrganizationBuilder().SetOrganizationType(OrganizationType.Central).BuildAndPersist(s); break; } var newDescription = DataProvider.Get <string>(); var newDetails = DataProvider.Get <string>(); var expectedEvt = Test.CreateInstance <IOrganizationUpdated>(e => { e.Organization = new OrganizationReference(org.Id, newOrganizationType, newDescription, newDetails, newReportingFrequency); e.Username = username; }); return(new { username, expectedEvt, Cmd = new UpdateOrganizationCommand(org.Id, newDescription, newDetails, newOrganizationType, newReportingFrequency, parent) }); }); var context = await Endpoint.Act <UpdateOrganizationCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.Cmd, ctx)); }); var evt = context.ExpectPublish <IOrganizationUpdated>(); Endpoint.AssertOnSqlSessionThat(AssemblySetupFixture.EndpointTestContainer, s => { var organization = s.Query <Organization>().Single(x => x.Id == testParams.Cmd.OrganizationId); organization.Should().NotBeNull(); organization.OrganizationType.Should().Be(testParams.Cmd.OrganizationType); organization.ReportingFrequency.Should().Be(testParams.Cmd.ReportingFrequency); organization.Description.Should().Be(testParams.Cmd.Description); organization.Details.Should().Be(testParams.Cmd.Details); organization.Parent.Should().Be(testParams.Cmd.Parent); organization.Timestamp.Should().Be(now); organization.IsDeleted.Should().Be(false); }); evt.Should().BeEquivalentTo(testParams.expectedEvt, e => e.Excluding(p => p.SerializedData)); evt.SerializedData.Should().NotBe(null); }