Ejemplo n.º 1
0
        public void UpdateForum()
        {
            var parentCategory = Substitute.For <Domain.Category>("category", 1, "desc");

            parentCategory.Id.Returns("1");

            var inputParameter = new Domain.Forum(parentCategory, "name", 1, "description");
            var command        = new UpdateForumCommand {
                Id = "1", Name = inputParameter.Name, SortOrder = inputParameter.SortOrder, Description = inputParameter.Description
            };
            var dto = Substitute.For <IForumDto>();

            var datastore = Substitute.For <IForumDatastore>();

            datastore.Update(inputParameter).Returns <IForumDto>(dto);
            var taskDatastore = Substitute.For <ITaskDatastore>();

            UpdateForumCommandHandler handler = new UpdateForumCommandHandler(datastore, taskDatastore);
            GenericValidationCommandHandlerDecorator <UpdateForumCommand> val =
                new GenericValidationCommandHandlerDecorator <UpdateForumCommand>(
                    handler,
                    new List <IValidator <UpdateForumCommand> > {
                new UpdateForumValidator(TestUtils.GetInt32IdValidator())
            }
                    );

            val.Execute(command);

            datastore.ReceivedWithAnyArgs(1).Update(inputParameter);
        }
    public void CanUpdateForum()
    {
      // Arrange
      CreateForumCommand cmd = new CreateForumCommand(new ForumId(), "Forum 1", "Blah blah");
      Service.Handle(cmd);

      Forum f2 = Repository.Get(cmd.Id).Aggregate;

      // Act
      UpdateForumCommand cmd2 = new UpdateForumCommand(cmd.Id, "Forum A", "Oh well");
      Service.Handle(cmd2);

      Forum f3 = Repository.Get(cmd.Id).Aggregate;

      // Assert
      Assert.AreEqual(cmd.Id, f3.Id);
      Assert.AreEqual("Forum A", f3.Title);
      Assert.AreEqual("Oh well", f3.Description);
    }
Ejemplo n.º 3
0
        public void Update(UpdateForumCommand cmd)
        {
            Condition.Requires(cmd, "cmd").IsNotNull();

            Publish(new ForumUpdatedEvent(cmd.Id, cmd.Title, cmd.Description));
        }
Ejemplo n.º 4
0
 public void Handle(UpdateForumCommand cmd)
 {
     Update(cmd, f => f.Update(cmd));
 }
    public void ItCannotUpdateNonExistingForum()
    {
      // Arrange
      UpdateForumCommand c = new UpdateForumCommand(new ForumId(), "Hello", "Blah");

      // Act + Assert
      AssertThrows<DomainException>(
        () => Service.Handle(c),
        ex => { Assert.AreEqual("NotCreated", ex.Name); });
    }