コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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));

        }