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 CreateForumAsForumChild() { var parentCategory = Substitute.For <Domain.Category>("category", 1, "desc"); parentCategory.Id.Returns("1"); var parentForum = Substitute.For <Domain.Forum>(parentCategory, "category", 1, "desc"); parentForum.Id.Returns("1"); var inputParameter = new Domain.Forum(parentForum, "name", 1, "description"); var command = new CreateForumCommand { ParentForumId = parentForum.Id, Name = inputParameter.Name, SortOrder = inputParameter.SortOrder, Description = inputParameter.Description }; var dto = Substitute.For <IForumDto>(); var categoryDatastore = Substitute.For <ICategoryDatastore>(); var datalayerCategory = Substitute.For <ICategoryDto>(); datalayerCategory.Id.Returns("1"); categoryDatastore.ReadById(parentCategory.Id).Returns(datalayerCategory); var datalayerForum = Substitute.For <IForumDto>(); datalayerForum.Id.Returns("1"); var datastore = Substitute.For <IForumDatastore>(); datastore.CreateAsForumChild(inputParameter).Returns <IForumDto>(dto); var taskDatastore = Substitute.For <ITaskDatastore>(); CreateForumCommandHandler handler = new CreateForumCommandHandler(categoryDatastore, datastore, taskDatastore); GenericValidationCommandHandlerDecorator <CreateForumCommand> val = new GenericValidationCommandHandlerDecorator <CreateForumCommand>( handler, new List <IValidator <NForum.CQS.Commands.Forums.CreateForumCommand> > { new NForum.CQS.Validators.Forums.CreateForumValidator(TestUtils.GetInt32IdValidator()) } ); val.Execute(command); datastore.ReceivedWithAnyArgs(1).CreateAsForumChild(inputParameter); }
public IForumDto Create(Domain.Forum forum) { Dbos.Category cat = this.datastore.ReadCategoryById(ObjectId.Parse(forum.CategoryId)); if (cat == null) { // TODO ?? throw new ArgumentException("Parent category not found"); } Dbos.Forum f = new Dbos.Forum { Name = forum.Name, Description = forum.Description, SortOrder = forum.SortOrder, Category = new CategoryRef { Id = cat.Id, Name = cat.Name }, Path = new ObjectId[] { } }; if (!String.IsNullOrWhiteSpace(forum.ParentForumId)) { Dbos.Forum parentForum = this.datastore.ReadForumById(ObjectId.Parse(forum.ParentForumId)); if (parentForum == null) { // TODO ?? throw new ArgumentException("Parent forum not found"); } f.ParentForum = new ForumRef { Id = parentForum.Id, Name = parentForum.Name }; f.Path = parentForum.Path.Union(new ObjectId[] { parentForum.Id }).ToArray(); } return(this.datastore.CreateForum(f).ToDto()); }
public IForumDto CreateAsForumChild(Domain.Forum forum) { throw new NotImplementedException(); }
public IForumDto Update(Domain.Forum forum) { throw new NotImplementedException(); }