public void GetById_ShouldReturnEmployee()
        {
            var employee = new Employee { Id = 1, FirstName = "Ted", LastName = "Mosby" };
            var mockContext = new Mock<InstantDeliveryContext>();
            mockContext.Setup(c => c.Employees).ReturnsDbSet(employee);

            var userStore = new Mock<UserStore<User>>(mockContext.Object);
            var userManager = new Mock<UserManager<User>>(userStore.Object);
            var controller = new EmployeesController(mockContext.Object, userManager.Object);
            var result = (controller.Get(employee.Id) as OkNegotiatedContentResult<EmployeeDto>)?.Content;

            Assert.Equal(result?.FirstName, employee.FirstName);
            Assert.Equal(result?.LastName, employee.LastName);
            Assert.Equal(result?.Id, employee.Id);
        }
        public void RemoveEmployee_ForDeliveredPackage_ShouldNotChangeItsStatus()
        {
            var package = new Package
            {
                Id = 1,
                Status = PackageStatus.Delivered
            };
            var employee = new Employee { Id = 1, FirstName = "Ted" };

            var mockContext = new Mock<InstantDeliveryContext>();
            mockContext.Setup(c => c.Packages).ReturnsDbSet(package);
            mockContext.Setup(c => c.Employees).ReturnsDbSet(employee);
            var userStore = new Mock<UserStore<User>>(mockContext.Object);
            var userManager = new Mock<UserManager<User>>(userStore.Object);
            var controller = new EmployeesController(mockContext.Object, userManager.Object);
            controller.Delete(employee.Id);

            Assert.Equal(PackageStatus.Delivered, package.Status);
        }
        public void RemoveEmployee_ForPackagesInDelivery_ShouldSetPackagesStatusBackToNew()
        {
            var package = new Package
            {
                Id = 1,
                Status = PackageStatus.InDelivery
            };
            var employee = new Employee { Id = 1, FirstName = "Ted", LastName = "Mosby" };
            employee.Packages.Add(package);

            var mockContext = new Mock<InstantDeliveryContext>();
            mockContext.Setup(c => c.Packages).ReturnsDbSet(package);
            mockContext.Setup(c => c.Employees).ReturnsDbSet(employee);

            var userStore = new Mock<UserStore<User>>(mockContext.Object);
            var userManager = new Mock<UserManager<User>>(userStore.Object);
            var controller = new EmployeesController(mockContext.Object, userManager.Object);
            controller.Delete(employee.Id);

            Assert.Equal(PackageStatus.InWarehouse, package.Status);
        }
        public void ChangeEmployeesVehicle_ShouldChangeEmployeeVehicle()
        {
            var employee = new Employee { FirstName = "Ted", LastName = "Mosby", Id = 1 };
            var vehicle = new Vehicle { Id = 1 };

            var mockContext = new Mock<InstantDeliveryContext>();
            mockContext.Setup(c => c.Employees).ReturnsDbSet(employee);
            mockContext.Setup(c => c.Vehicles).ReturnsDbSet(vehicle);

            var userStore = new Mock<UserStore<User>>(mockContext.Object);
            var userManager = new Mock<UserManager<User>>(userStore.Object);
            var controller = new EmployeesController(mockContext.Object, userManager.Object);
            controller.ChangeVehicle(employee.Id, vehicle.Id);

            Assert.Equal(employee.Vehicle.Id, 1);
        }