public void ShouldReturnTwilioResponseWithNineFavouritesWhenOnlyNineFavourites() { var profileId = 324784; var profileManager = new Mock<IProfileManager>(); var refUnitedAcctManager = new Mock<IRefugeesUnitedAccountManager>(); var routeProvider = new Mock<IIVRRouteProvider>(); var favs = new List<RefugeesUnitedApi.ApiEntities.Profile>(); StringBuilder favsSb = new StringBuilder(); StringBuilder favsSaySb = new StringBuilder(); for (int i = 0; i < 9; i++) { favs.Add(new RefugeesUnitedApi.ApiEntities.Profile() { ProfileId = i, FirstName = "firstname" + i, Surname = "surname" + i }); favsSb.Append(i); favsSb.Append(","); favsSaySb.Append(string.Format(" <Say>To send a message to firstname{0} surname{0} press {1}</Say>\r\n", i, i + 1)); } string favsId = favsSb.ToString().Substring(0, favsSb.Length - 1); refUnitedAcctManager.Setup(m => m.GetFavourites(profileId, 0)).Returns(favs); var logic = new IVRMainLogic(profileManager.Object, refUnitedAcctManager.Object, routeProvider.Object); var response = logic.ListFavourites(new Twilio.Mvc.VoiceRequest(), profileId, 0); Assert.IsNotNull(response); Assert.AreEqual(twilioSayListingFavourites, response.Element.FirstNode.ToString()); Assert.AreEqual(string.Format(twilioGatherFavouriteListResponse, profileId, favsId, 0, favsSaySb.ToString()), response.Element.LastNode.ToString()); }
public void ShouldReturnTwilioResponseWithNoFavourites() { var profileId = 324784; var profileManager = new Mock<IProfileManager>(); var refUnitedAcctManager = new Mock<IRefugeesUnitedAccountManager>(); var routeProvider = new Mock<IIVRRouteProvider>(); routeProvider.Setup(m => m.GetUrlMethod(RefUnitedIVRPlatform.Common.IVRRoutes.PLAY_MAIN_MENU)).Returns("/IVRMain/MainMenu"); var logic = new IVRMainLogic(profileManager.Object, refUnitedAcctManager.Object, routeProvider.Object); var response = logic.ListFavourites(new Twilio.Mvc.VoiceRequest(), profileId, 0); Assert.IsNotNull(response); Assert.AreEqual(twilioSayNoFavourites, response.Element.FirstNode.ToString()); Assert.AreEqual(twilioRedirect, response.Element.LastNode.ToString()); }
public void ShouldReturnTwilioResponseWithThreeFavouritesFromPage2WhenTwelveFavourites() { var profileId = 324784; var profileManager = new Mock<IProfileManager>(); var apiRequest = new Mock<IApiRequest>(); var refUnitedAcctManager = new RefugeesUnitedAccountManager(apiRequest.Object); var routeProvider = new Mock<IIVRRouteProvider>(); //this is what we are testing! var logic = new IVRMainLogic(profileManager.Object, refUnitedAcctManager, routeProvider.Object); var favs = new List<RefugeesUnitedApi.ApiEntities.Profile>(); StringBuilder favsSb = new StringBuilder(); StringBuilder favsSaySb = new StringBuilder(); int diff = -9; for (int i = 0; i < 12; i++) { favs.Add(new RefugeesUnitedApi.ApiEntities.Profile() { ProfileId = i, FirstName = "firstname" + i, Surname = "surname" + i }); if ((i % 9) == 0) { favsSaySb = new StringBuilder(); favsSb = new StringBuilder(); diff += 9; } favsSb.Append(i); favsSb.Append(","); favsSaySb.Append(string.Format(" <Say>To send a message to firstname{0} surname{0} press {1}</Say>\r\n", i, (i + 1) - diff)); } string favsId = favsSb.ToString().Substring(0, favsSb.Length - 1); apiRequest.Setup(m => m.GetFavourites(profileId)).Returns(favs); var response = logic.ListFavourites(new Twilio.Mvc.VoiceRequest(), profileId, 1); Assert.IsNotNull(response); Assert.AreEqual(twilioSayListingFavourites, response.Element.FirstNode.ToString()); Assert.AreEqual(string.Format(twilioGatherFavouriteListResponse, profileId, favsId, 1, favsSaySb.ToString()), response.Element.LastNode.ToString()); }