示例#1
0
        public void CanPostCommands()
        {
            var commandManager = new Mock <ICommandManager>();
            var commandRepo    = new Mock <ICommandStateRepository>();

            var projectsService  = new Mock <IProjectService>();
            var productsService  = new Mock <IProductService>();
            var contactsService  = new Mock <IContactService>();
            var companiesService = new Mock <ICompanyService>();

            var projectCommandDto = new Fakes.RenameProjectCommandDto();
            var productCommandDto = new Fakes.RenameProductCommandDto();

            commandRepo.Setup(s => s.CreateCommandState()).Returns(new Fakes.CommandState());

            var projectCommand = new Fakes.RenameProjectCommand(projectCommandDto, commandRepo.Object);
            var productCommand = new Fakes.RenameProductCommand(productCommandDto, commandRepo.Object);

            commandManager.Setup(s => s.ProcessCommand(projectCommandDto)).Returns(projectCommand);
            commandManager.Setup(s => s.ProcessCommand(productCommandDto)).Returns(productCommand);

            var sut       = new CommandsController(commandManager.Object, productsService.Object, projectsService.Object, contactsService.Object, companiesService.Object);
            var sutResult = sut.Post(new List <CommandDto> {
                projectCommandDto, productCommandDto
            });

            Assert.Equal(2, sutResult.Count());
        }
 public RenameProductCommand(RenameProductCommandDto dto, ICommandStateRepository repo)
 {
     this.CommandRepository = repo;
     this.CreatedOn         = dto.CreatedOn;
     this.EntityGuid        = dto.EntityGuid;
     this.CommandTypeId     = dto.Name + dto.Entity + "Command";
     this.Name         = "new";
     this.OriginalName = "old";
     this.ReceivedOn   = DateTime.Now;
 }