public void CreatePostShouldInsertOrganization() { // Arrange CreateSut(); OrganizationEditModel model = AgincourtAware; IRequest <int> command = new OrganizationEditCommand() { Organization = model }; _mediator.Setup(y => y.Send(It.IsAny <OrganizationNameUniqueQuery>())).Returns(() => { return(true); }); _mediator.Setup(x => x.Send(It.IsAny <OrganizationEditCommand>())).Returns(() => { IRequestHandler <OrganizationEditCommand, int> handler = new OrganizationEditCommandHandler(Context); return(handler.Handle((OrganizationEditCommand)command)); }); // Act _sut.Edit(model); // Assert Assert.Single(Context.Organizations.Where(t => t.Name == model.Name)); }
public void AddOrganization() { // Arrange Organization org = CreateAgincourtAwareness(); OrganizationEditModel orgModel = OrganizationEditCommandHandlerTests.ToEditModel_Organization(org); // Act OrganizationEditCommandHandler handler = new OrganizationEditCommandHandler(Context); int id = handler.Handle(new OrganizationEditCommand() { Organization = orgModel }); Organization fetchedOrg = Context.Organizations.Where(t => t.Id == id).First(); // Assert Assert.Single(Context.Organizations.Where(t => t.Id == id)); Assert.Equal(Context.Entry(fetchedOrg).State, Microsoft.Data.Entity.EntityState.Unchanged); }
public void AddOrganizationWithUnknownPostalCode() { // Arrange Organization org = CreateAgincourtAwareness(); OrganizationEditModel orgModel = OrganizationEditCommandHandlerTests.ToEditModel_Organization(org); // Act OrganizationEditCommandHandler handler = new OrganizationEditCommandHandler(Context); int id = handler.Handle(new OrganizationEditCommand() { Organization = orgModel }); Organization fetchedOrg = Context.Organizations.Where(t => t.Id == id).First(); // Assert Assert.Single(Context.Organizations.Where(t => t.Id == id)); Assert.Equal(fetchedOrg.Location.City, fetchedOrg.Location.PostalCode.City); Assert.Equal(fetchedOrg.Location.State, fetchedOrg.Location.PostalCode.State); }
public void CreatePostShouldInsertOrganization() { // Arrange CreateSut(); OrganizationEditModel model = AgincourtAware; IRequest<int> command = new OrganizationEditCommand() { Organization = model }; _mediator.Setup(x => x.Send(It.IsAny<OrganizationEditCommand>())).Returns(() => { IRequestHandler<OrganizationEditCommand, int> handler = new OrganizationEditCommandHandler(Context); return handler.Handle((OrganizationEditCommand)command); }); // Act _sut.Edit(model); // Assert Assert.Single(Context.Organizations.Where(t => t.Name == model.Name)); }