示例#1
0
        public void VehicleExistsShouldReturnFalseOnEmptyRepository()
        {
            var repository = new Mock <IDeletableEntityRepository <Vehicle> >();

            repository.Setup(r => r.All()).Returns(new List <Vehicle>().AsQueryable());
            var    service   = new VehiclesService(repository.Object);
            string randomVIN = "WAUZZZ1KZ8N123456";

            Assert.False(service.VihicleExists(randomVIN));
            repository.Verify(x => x.All(), Times.Once);
        }
示例#2
0
        public void VehicleExistsShouldReturnTrueOnExistingVIN()
        {
            var repository = new Mock <IDeletableEntityRepository <Vehicle> >();

            repository.Setup(r => r.All()).Returns(new List <Vehicle>
            {
                new Vehicle()
                {
                    VIN = "WAUZZZ1KZ8N123456"
                },
            }.AsQueryable());
            var    service     = new VehiclesService(repository.Object);
            string existingVIN = "WAUZZZ1KZ8N123456";

            Assert.True(service.VihicleExists(existingVIN));
        }