示例#1
0
        public void Should_ReturnError_If_BrandName_AlreadyExists_OnAdd()
        {
            BrandRepository.Setup(r => r.GetByName(It.IsAny <string>())).Returns(NewValidBrand);

            var service = new VehicleService(UoW.Object, BrandRepository.Object);

            var result = service.AddBrand(NewValidBrand);

            Assert.False(result.Success);
            Assert.Single(result.Errors);
        }
示例#2
0
        public void Should_AddBrand_Success()
        {
            BrandRepository.Setup(r => r.Add(It.IsAny <Brand>())).Returns(NewValidBrand);
            UoW.Setup(u => u.Commit()).Returns(true);

            var service = new VehicleService(UoW.Object, BrandRepository.Object);

            var result = service.AddBrand(NewValidBrand);

            Assert.True(result.Success);
        }
示例#3
0
        public void Should_ReturnErrorOnSaveThrows()
        {
            BrandRepository.Setup(r => r.Add(It.IsAny <Brand>())).Returns(NewValidBrand);
            UoW.Setup(u => u.Commit()).Throws(new Exception("DataBase Error"));

            var service = new VehicleService(UoW.Object, BrandRepository.Object);

            var result = service.AddBrand(NewValidBrand);

            Assert.False(result.Success);
            Assert.Single(result.Errors);
        }