public async Task NewMeterReading_given_invalid_request_returns_false() { var client = new Mock <IXellentAPI>(); var config = new Mock <IConfig>(); client.Setup(s => s.newMeterReading(It.IsAny <NewMeterReadingRequest>())) .Returns(new newMeterReadingResponse() { ErrorCode = "4", ResponseCode = "invalid", ResponseMessage = "" }); var active = new MeterReadingOrder() { PrevReading = "7000" }; var list = new List <MeterReadingOrder>() { active }; client.Setup(s => s.getactiveMeterReadings(It.IsAny <ActiveMeterReadingRequest>())) .Returns(new MeterReadingOrderResponse() { MeterReadingOrders = list.ToArray() }); var service = new MeterReadingSoapService(client.Object, config.Object); var result = await service.NewMeterReadingAsync("7373"); Assert.False(result.Item1); Assert.Equal("invalid", result.Item2); }
public async Task GetActiveMeterReading_returns_active_readings() { var client = new Mock <IXellentAPI>(); var config = new Mock <IConfig>(); var entry = new MeterReadingOrder(); var list = new List <MeterReadingOrder>() { entry }; client.Setup(s => s.getactiveMeterReadings(It.IsAny <ActiveMeterReadingRequest>())). Returns(new MeterReadingOrderResponse() { MeterReadingOrders = list.ToArray() }); var service = new MeterReadingSoapService(client.Object, config.Object); var activeReading = new MeterReadingOrder(); var result = await service.GetActiveMeterReadingsAsync(); Assert.True(result.Item1); Assert.NotNull(result.Item2); }
public async Task GetActiveMeterReading_given_no_active_readings_returns_false() { var client = new Mock <IXellentAPI>(); var config = new Mock <IConfig>(); var entry = new MeterReadingOrder(); var list = new List <MeterReadingOrder>() { entry }; client.Setup(s => s.getactiveMeterReadings(It.IsAny <ActiveMeterReadingRequest>())) .Throws <Exception>(); var service = new MeterReadingSoapService(client.Object, config.Object); var activeReading = new MeterReadingOrder(); var result = await service.GetActiveMeterReadingsAsync(); Assert.False(result.Item1); Assert.Null(result.Item2); }