public async Task RemoveLtcPharmacy() { var customerSvc = Container.Resolve <ICustomerAppService>(); var customerId = await AddCustomerAsync(customerSvc); var customer = await customerSvc.GetAsync(customerId); var pruittId = customer !.LtcPharmacies.Single(p => p.Name == "Pruitt").Id; await customerSvc.RemoveLtcPharmacyAsync(customerId, pruittId); customer = await customerSvc.GetAsync(customerId); CollectionAssert.AreEquivalent( new List <string> { "Alixa" }, customer !.LtcPharmacies.Select(p => p.Name).ToList() ); }
public async Task ChangeProperty() { var customerSvc = Container.Resolve <ICustomerAppService>(); var auditSvc = Container.Resolve <IAuditAppService>(); var customerId = await AddCustomerAsync(customerSvc); var customer = await customerSvc.GetAsync(customerId); var pruittId = customer !.LtcPharmacies.Single(p => p.Name == "Pruitt").Id; await customerSvc.RenameLtcPharmacyAsync(customerId, pruittId, "Pruitt2"); var auditRecords = (await auditSvc.ListAsync("LtcPharmacy", pruittId.Guid.ToString(), 0, 1000)) !.Items; var auditRecord = auditRecords.Single(r => r.Entity == "LtcPharmacy" && r.Event == "Modified"); Assert.AreEqual(new AppAuthContext().UserIdString, auditRecord.UserId); Assert.AreEqual(new AppAuthContext().UserName, auditRecord.UserName); Assert.AreEqual("Customer", auditRecord.Aggregate); Assert.AreEqual(customerId.Guid.ToString(), auditRecord.AggregateId); Assert.AreEqual("LtcPharmacy", auditRecord.Entity); Assert.AreEqual(pruittId.Guid.ToString(), auditRecord.EntityId); var changes = auditRecord.Changes.FromDbJson <List <AuditPropertyDto> >() !; Assert.AreEqual(1, changes.Count); Assert.IsNotNull( changes.SingleOrDefault(p => p.Name == "Name" && p.From == "Pruitt" && p.To == "Pruitt2") ); AssertDoesNotIncludeIgnoredFields(changes); var customerAuditRecords = (await auditSvc.ListAsync("Customer", customerId.Guid.ToString(), 0, 1000)) !.Items; Assert.IsNotNull( customerAuditRecords.SingleOrDefault(r => r.Entity == "LtcPharmacy" && r.Event == "Modified") ); }