public void Should_return_null_when_negative_or_zero_device_id_passed(int negativeOrZeroDeviceId) { //Arrange _deviceApiService = new DeviceApiService(_tenantMappingService.Object, _deviceRepository.Object); //Act var result = _deviceApiService.GetDeviceById(negativeOrZeroDeviceId); //Assert result.ShouldBeNull(); }
public void Should_return_null_when_null_is_returned_by_repository() { int deviceId = 3; //Arrange _deviceRepository.Setup(x => x.Table).Returns(new List <Device>().AsQueryable()); _deviceRepository.Setup(x => x.GetById(deviceId)).Returns(new Device()); _deviceApiService = new DeviceApiService(_tenantMappingService.Object, _deviceRepository.Object); //Act var result = _deviceApiService.GetDeviceById(deviceId); //Assert result.ShouldBeNull(); }
public void Should_return_same_device_when_device_is_returned_by_repository() { int deviceId = 3; Device device = new Device() { Id = 3, ModelNo = "some model" }; //Arrange var list = new List <Device>(); list.Add(device); _deviceRepository.Setup(x => x.Table).Returns(list.AsQueryable()); _deviceRepository.Setup(x => x.GetById(deviceId)).Returns(device); _deviceApiService = new DeviceApiService(_tenantMappingService.Object, _deviceRepository.Object); //Act var result = _deviceApiService.GetDeviceById(deviceId); //Assert result.ShouldBeTheSameAs(device); }