Esempio n. 1
0
        public void CheckOwnershipShouldReturnFalseOnEmptyRepository()
        {
            var repository = new Mock <IDeletableEntityRepository <Vehicle> >();

            repository.Setup(r => r.All()).Returns(new List <Vehicle>().AsQueryable());
            var    service         = new VehiclesService(repository.Object);
            string randomUserId    = "testId";
            int    randomVehicleId = 1;

            Assert.False(service.CheckOwnership(randomUserId, randomVehicleId));
        }
Esempio n. 2
0
        public void CheckOwnershipShouldReturnTrueOnCorrectVehicleId()
        {
            var    repository        = new Mock <IDeletableEntityRepository <Vehicle> >();
            string randomUserId      = "testId";
            int    existingVehicleId = 1;

            repository.Setup(r => r.All()).Returns(new List <Vehicle>
            {
                new Vehicle {
                    Id = existingVehicleId, OwnerId = randomUserId
                },
            }.AsQueryable());
            var service = new VehiclesService(repository.Object);

            Assert.True(service.CheckOwnership(randomUserId, existingVehicleId));
        }