public async Task Should_clear_calendar() { _googleSpreadSheetClient .Setup(s => s.Clear( It.Is <string>(id => id == "1"), It.Is <string>(range => range == "Calendar!A:B"), It.IsAny <ClearValuesRequest>()) ) .ReturnsAsync(new ClearValuesResponse { SpreadsheetId = "1" }); var sut = new AlertOwnerService(_googleSpreadSheetClient.Object, _converter.Object, _timeService.Object, _options); await sut.ClearCalendar(); _googleSpreadSheetClient.Verify(s => s.Clear( It.Is <string>(id => id == "1"), It.Is <string>(range => range == "Calendar!A:B"), It.IsAny <ClearValuesRequest>()), Times.Once ); }
Should_update_calendar() { _googleSpreadSheetClient .Setup(s => s.Update( It.Is <string>(id => id == "1"), It.Is <string>(range => range == "Calendar!A:B"), It.IsAny <IEnumerable <IEnumerable <object> > >()) ) .ReturnsAsync(new UpdateValuesResponse { SpreadsheetId = "1" }); var sut = new AlertOwnerService(_googleSpreadSheetClient.Object, _converter.Object, _timeService.Object, _options); var request = new List <Shift> { new Shift(new TeamMate("1", "IronMan", "LA"), new LocalDate(2019, 12, 1)) }; await sut.WriteCalendar(request); _googleSpreadSheetClient.Verify(s => s.Update( It.Is <string>(id => id == "1"), It.Is <string>(range => range == "Calendar!A:B"), It.IsAny <IEnumerable <IEnumerable <object> > >()), Times.Once ); }
public async Task Should_return_teamMates() { _googleSpreadSheetClient .Setup(s => s.Get(It.Is <string>(id => id == "1"), It.Is <string>(range => range == "TeamMates!A:C"))) .ReturnsAsync(new ValueRange { Values = new List <IList <object> > { new List <object> { "IronMan", "1", "LA" } } }); var sut = new AlertOwnerService(_googleSpreadSheetClient.Object, _converter.Object, _timeService.Object, _options); var actual = (await sut.GetTeamMates()).ToList().First(); Assert.AreEqual("1", actual.Id); Assert.AreEqual("IronMan", actual.Name); Assert.AreEqual("LA", actual.CountryCode); }
public async Task Should_return_patronDays() { _googleSpreadSheetClient .Setup(s => s.Get(It.Is <string>(id => id == "1"), It.Is <string>(range => range == "PatronDays!A:B"))) .ReturnsAsync(new ValueRange { Values = new List <IList <object> > { new List <object> { "25/12", "LP" } } }); _timeService .Setup(s => s.Now) .Returns(new LocalDate(2019, 12, 12)); var sut = new AlertOwnerService(_googleSpreadSheetClient.Object, _converter.Object, _timeService.Object, _options); var actual = (await sut.GetPatronDays()).First(); Assert.AreEqual(new LocalDate(2019, 12, 25).ToString(), actual.Day.ToString()); Assert.AreEqual("LP", actual.CountryCode); }
public async Task Should_return_shifts() { _googleSpreadSheetClient .Setup(s => s.Get(It.Is <string>(id => id == "1"), It.Is <string>(range => range == "Calendar!A:B"))) .ReturnsAsync(new ValueRange { Values = new List <IList <object> > { new List <object> { "25/12/2019", "IronMan" }, new List <object> { "26/12/2019", "Hulk" }, new List <object> { "27/12/2019", "Thor" }, new List <object> { "28/12/2019", "IronMan" } } }); var teamMates = new List <TeamMate> { new TeamMate("1", "IronMan", "LA"), new TeamMate("2", "Hulk", "NY"), new TeamMate("3", "Thor", "AZ") }; _timeService .Setup(s => s.Now) .Returns(new LocalDate(2019, 12, 25)); _converter.SetupSequence(s => s.ParseValueFromString(It.IsAny <string>())) .Returns(new LocalDate(2019, 12, 25)) .Returns(new LocalDate(2019, 12, 26)); var sut = new AlertOwnerService(_googleSpreadSheetClient.Object, _converter.Object, _timeService.Object, _options); var(today, tomorrow) = await sut.GetShift(teamMates); Assert.AreEqual(new LocalDate(2019, 12, 25).ToString(), today.Schedule.ToString()); Assert.AreEqual("1", today.TeamMate.Id); Assert.AreEqual("IronMan", today.TeamMate.Name); Assert.AreEqual(null, today.TeamMate.CountryCode); Assert.AreEqual(new LocalDate(2019, 12, 26).ToString(), tomorrow.Schedule.ToString()); Assert.AreEqual("2", tomorrow.TeamMate.Id); Assert.AreEqual("Hulk", tomorrow.TeamMate.Name); Assert.AreEqual(null, tomorrow.TeamMate.CountryCode); }
public async Task Should_return_calendar() { _googleSpreadSheetClient .Setup(s => s.Get(It.Is <string>(id => id == "1"), It.Is <string>(range => range == "Calendar!A:B"))) .ReturnsAsync(new ValueRange { Values = new List <IList <object> > { new List <object> { "01/12/2019", "IronMan", "LA" } } }); _converter.Setup(s => s .ParseValueFromString(It.Is <string>(str => string.Equals(str, "01/12/2019", StringComparison.InvariantCulture)))) .Returns(new LocalDate(2019, 12, 1)); var sut = new AlertOwnerService(_googleSpreadSheetClient.Object, _converter.Object, _timeService.Object, _options); var actual = (await sut.GetCalendar(new List <TeamMate> { new TeamMate("1", "IronMan", "LA") })).Single(); var expectedSchedule = new LocalDate(2019, 12, 1); Assert.AreEqual(expectedSchedule, actual.Schedule); const string expectedId = "1"; Assert.AreEqual(expectedId, actual.TeamMate.Id); const string expectedName = "IronMan"; Assert.AreEqual(expectedName, actual.TeamMate.Name); }