예제 #1
0
        public EditToolViewModel ToolToToolViewModel(Tool tool)
        {
            var viewModel = new EditToolViewModel {Id = tool.Id, Name = tool.Name, Description = tool.Description};
            if (tool.StuffCategory != null)
                viewModel.StuffCategory = tool.StuffCategory;
            if (tool.StuffManufacture != null)
                viewModel.StuffManufacture = tool.StuffManufacture;

            return viewModel;
        }
예제 #2
0
 private Tool MapToolViewModelToCreate(EditToolViewModel toolViewModel)
 {
     var tool = new Tool
     {
         Id = toolViewModel.Id,
         Name = toolViewModel.Name,
         Description = toolViewModel.Description,
         StuffCategory = _stuffCategoryService.FindStuffCategory(toolViewModel.StuffCategoryId),
         StuffManufacture = _stuffManufactureService.FindStuffManufacture(toolViewModel.StuffManufactureId)
     };
     return tool;
 }
예제 #3
0
        public void Should_Map_CheckinToolTabViewModel_To_CheckinTool_When_All_Fields_Are_Populated()
        {
            //Arrange
            var employee = new Employee
            {
                Id = 1,
                Name = "Celso"
            };

            var tool = new Tool
            {
                Id = 1,
                Name = "Ferramenta 1"
            };

            var companyArea = new CompanyArea
            {
                Id = 1,
                Name = "Portões"
            };

            var createCheckinToolTabViewModel = CheckinToolDummies.CreateOneCheckinToolTabViewModel(tool.Id);

            var holderServiceMock = new Mock<IHolderService>();
            var toolServiceMock = new Mock<IToolService>();
            var checkinToolServiceMock = new Mock<ICheckinToolService>();
            var companyAreaServiceMock = new Mock<ICompanyAreasService>();

            holderServiceMock.Setup(x => x.FindHolderByName(createCheckinToolTabViewModel.HolderName))
                .Returns(employee);
            toolServiceMock.Setup(x => x.FindTool(createCheckinToolTabViewModel.ToolId))
                .Returns(tool);
            companyAreaServiceMock.Setup(x => x.FindCompanyAreaByName(createCheckinToolTabViewModel.CompanyAreaName))
                .Returns(companyArea);

            var toolMapper = new ToolMapper(null, null, toolServiceMock.Object, holderServiceMock.Object, companyAreaServiceMock.Object, checkinToolServiceMock.Object);

            //Act
            var checkinTool = toolMapper.MapCheckinToolTabViewModelToCheckinTool(createCheckinToolTabViewModel);

            //Assert
            checkinToolServiceMock.VerifyAll();
            toolServiceMock.VerifyAll();
            holderServiceMock.VerifyAll();
            Assert.IsNotNull(checkinTool.EmployeeCompanyHolderId);
            Assert.IsNotNull(checkinTool.Tool);
            Assert.IsNotNull(checkinTool.CheckinDateTime);
            Assert.IsNotNull(checkinTool.CompanyAreaId);
        }