public async void CheckIsMember_OnValidQuery_OkRequest() { //Arrange var query = "123456789"; var persistenceMock = new Mock <IFriendsPersistence>(); persistenceMock .Setup(p => p.Friends.IsMemberAsync(query)) .ReturnsAsync(true); var mapperMock = new Mock <IMapper>(); var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var httpContextMock = new Mock <DefaultHttpContext>(null); httpContextMock .SetupGet(am => am.User.Identity.Name) .Returns(query); //Act controller.ControllerContext.HttpContext = httpContextMock.Object; var response = await controller.IsMember(query); //Assert Assert.IsType <OkResult>(response); }
public async void FindFriend_OnUnknownPhoneNumber_NotFound(string phoneNumber) { //Arrange var mapperMock = new Mock <IMapper>(); var persistenceMock = new Mock <IFriendsPersistence>(); persistenceMock .Setup(r => r.Friends .FindByNameAsync(phoneNumber)) .Returns(Task.FromResult <ApplicationUser>(null)); var httpContextMock = new Mock <DefaultHttpContext>(null); httpContextMock .SetupGet(am => am.User.Identity.Name) .Returns("Somebody"); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); controller.ControllerContext.HttpContext = httpContextMock.Object; var respone = await controller.FindUser(phoneNumber); //Assert Assert.IsType <NotFoundResult>(respone); }
public async void FindFriend_OnOkResponse_OkWithValidUserDto(string phoneNumber) { //Arrange var fakeUser = new ApplicationUser { UserName = phoneNumber }; var fakeDto = new UserDto { Username = phoneNumber }; var mapperMock = new Mock <IMapper>(); mapperMock .Setup(m => m.Map <UserDto>(fakeUser)) .Returns(fakeDto); var persistenceMock = new Mock <IFriendsPersistence>(); persistenceMock .Setup(r => r.Friends .FindByNameAsync(phoneNumber)) .ReturnsAsync(fakeUser); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var respone = await controller.FindUser(phoneNumber); var dto = ((OkObjectResult)respone).Value as UserDto; //Assert Assert.IsType <OkObjectResult>(respone); Assert.IsType <UserDto>(dto); Assert.Equal(phoneNumber, dto.Username); }
public void Test1() { FriendsController x = new FriendsController(); var y = x.Get(); Assert.NotNull(y); }
public FriendControllerTests() { _contactServiceMock = new Mock <IContactService>(); _gmailServiceMock = new Mock <IGMailService>(); _gamServiceMock = new Mock <IGameService>(); _venueServiceMock = new Mock <IVenueService>(); _sut = new FriendsController(_contactServiceMock.Object, _gmailServiceMock.Object, _gamServiceMock.Object, _venueServiceMock.Object); }
public void TestMethodGetFriends() { //arrange FriendsController friendcontroller = new FriendsController(); //act var friends = friendcontroller.GetFriends(); //assert Assert.IsNotNull(friends); }
public void FriendsController_Returns_List_Of_Friends() { var ctrl = new FriendsController(); var friends = ctrl.Get().ToList(); Assert.Equal(3, friends.Count()); Assert.Equal("Joe", friends[0].Name); Assert.Equal("Jane", friends[1].Name); Assert.Equal("Jim", friends[2].Name); }
public void Delete_ReturnsNotFound_IdIsNull() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.Delete(null); Assert.IsType <NotFoundResult>(result.Result); }
private void Awake() { if (instance == null) { instance = this; //DontDestroyOnLoad(gameObject); } else if (instance != null) { //Destroy(gameObject); } }
public async void CheckIsMember_OnEmptyQuery_BadRequest() { //Arrange var persistenceMock = new Mock <IFriendsPersistence>(); var mapperMock = new Mock <IMapper>(); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var response = await controller.IsMember(null); //Assert Assert.IsType <BadRequestResult>(response); }
public async void FindFriend_OnEmptyPhoneNumber_BadRequest() { //Arrange var mapperMock = new Mock <IMapper>(); var persistenceMock = new Mock <IFriendsPersistence>(); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var response = await controller.FindUser(string.Empty); //Assert Assert.IsType <BadRequestResult>(response); }
public void TestAddGet1() { //Arrange=preparacion FriendsController friend = new FriendsController(); int numa = 3; int numb = 4; int numres = 7; //Act=ejecucion int result = friend.Add(numa, numb); //Assert=verificacion Assert.AreEqual(numres, result); }
public void DeleteConfirmed_ReturnBadRequest_BadDelete() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(r => r.RemoveFriendAsync(It.IsAny <int>())) .ReturnsAsync(false); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.DeleteConfirmed(It.IsAny <int>()); Assert.IsType <BadRequestResult>(result.Result); }
public void Delete_ReturnsNotFound_FriendIsNull() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(r => r.GetFriendAsync(It.IsAny <int>())) .ReturnsAsync(NullFriend()); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.Delete(null); Assert.IsType <NotFoundResult>(result.Result); }
public void DeleteConfirmed_ReturnRedirect_GoodDelete() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(r => r.RemoveFriendAsync(It.IsAny <int>())) .ReturnsAsync(true); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.DeleteConfirmed(It.IsAny <int>()); var redirectResult = Assert.IsType <RedirectToActionResult>(result.Result); Assert.Equal("Index", redirectResult.ActionName); }
public void Delete_ReturnsNotFound_WithFriend() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(r => r.GetFriendAsync(It.IsAny <int>())) .ReturnsAsync(GetFriend()); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.Delete(It.IsAny <int>()); var viewResult = Assert.IsType <ViewResult>(result.Result); var model = Assert.IsAssignableFrom <FriendViewModel>( viewResult.ViewData.Model); }
public void GetFacebookFriendsTest() { //Arrange var facebook = Mock.Of <IFacebookService>(); var facebookMock = Mock.Get(facebook); facebookMock.Setup(m => m.GetFriends()).Returns("{json of friends}"); var sut = new FriendsController(facebook); //Act var actionResult = sut.GetFacebookFriends(); //Assert //...do your assertions here }
public IEnumerator SetUp() { var prefab = AssetDatabase.LoadAssetAtPath(PREFAB_PATH, (typeof(GameObject))) as GameObject; contextMenu = UnityEngine.Object.Instantiate(prefab).GetComponent <UserContextMenu>(); friendsController = (new GameObject()).AddComponent <FriendsController>(); profileController = (new GameObject()).AddComponent <UserProfileController>(); profileController.AddUserProfileToCatalog(new UserProfileModel() { name = TEST_USER_ID, userId = TEST_USER_ID }); yield break; }
public void VerifyUserName_ReturnFalse() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); ApplicationUser friend = null; var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(repo => repo.FindUserAsync(It.IsAny <string>())) .ReturnsAsync(friend); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.VerifyUserName(It.IsAny <string>()); var jsonResult = Assert.IsType <JsonResult>(result.Result); Assert.Equal(false, jsonResult.Value); }
public async void FindFriends_OnAnyFindingMatches_OkWithMatchingUserDto() { //Arrange var requestPhoneNumbers = new List <string> { "123", "456", "789" }; var usersInDb = new List <ApplicationUser> { new ApplicationUser { UserName = "******" }, new ApplicationUser { UserName = "******" } }; var fakeDtos = new List <UserDto>(); usersInDb.ForEach(a => fakeDtos.Add(new UserDto { Username = a.UserName })); var persistenceMock = new Mock <IFriendsPersistence>(); persistenceMock .Setup(r => r.Friends .FindByNameRangeAsync(requestPhoneNumbers)) .ReturnsAsync(usersInDb); var mapperMock = new Mock <IMapper>(); mapperMock .Setup(m => m.Map <IEnumerable <UserDto> >(usersInDb)) .Returns(fakeDtos); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var response = await controller.FindUsers(requestPhoneNumbers); var dtos = ((OkObjectResult)response).Value as IEnumerable <UserDto>; //Assert Assert.IsType <OkObjectResult>(response); Assert.Equal(usersInDb.Count, dtos.Count()); }
public void Create_ReturnsBadRequest_FailCreate() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(repo => repo.AddFriendAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(false); FriendViewModel friendViewModel = new FriendViewModel(); friendViewModel.FriendUniqueName = "Test_User"; var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.Create(friendViewModel); Assert.IsType <BadRequestResult>(result.Result); }
public void Index_ReturnsAViewResult_WithAllFriends() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(repo => repo.GetAllFriendsAsync(It.IsAny <string>())) .ReturnsAsync(GetFriends()); var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.Index(); var viewResult = Assert.IsType <ViewResult>(result.Result); var model = Assert.IsAssignableFrom <IEnumerable <FriendViewModel> >( viewResult.ViewData.Model); Assert.Equal(2, model.Count()); }
public void initializeFriendsController(List <object> friends, FriendsController friendController) { for (int i = 0; i < friends.Count && i < maxFriendsToShow; i++) { Dictionary <string, object> friendInfo = ((Dictionary <string, object>)(friends [i])); string playerID = (string)friendInfo ["id"]; //print (friendInfo.Keys.ToCommaSeparateList ()); string playerName = (string)friendInfo ["name"]; Texture playerImage = new Texture(); if (FacebookPersistentData.GetInstance().containTextureByID(playerID)) { playerImage = FacebookPersistentData.GetInstance().getTextureById(playerID); } friendController.addFriend(playerID, playerName, playerImage); } friendController.initializeFriends(); }
public void AddingFriendworks() { //Arrange var mockContext = new Mock <friendManagerContext>(); FriendsController controller = new FriendsController(mockContext.Object); var friend = new Friend { Name = "Maciej Maciejowski", FirstMeetDate = DateTime.Parse("2012-12-12 14:53:00"), BiggestSecret = "Dislikes Charmander", Likeability = 12.12M }; //Act var result = controller.Create(friend); mockContext.Verify(ctx => ctx.Add(friend)); }
public void Create_ReturnsRedirect_SuccessfulCreate() { var mockUserManager = UserMockService.BaseUser(); var mapper = MapperService.DefaultMapper(); var mockRepo = new Mock <IFriendRepository>(); mockRepo.Setup(repo => repo.AddFriendAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(true); FriendViewModel friendViewModel = new FriendViewModel(); friendViewModel.FriendUniqueName = "Test_User"; var controller = new FriendsController(mapper, mockUserManager.Object, mockRepo.Object); var result = controller.Create(friendViewModel); var redirectResult = Assert.IsType <RedirectToActionResult>(result.Result); Assert.Equal("Index", redirectResult.ActionName); }
public FriendsController_Tests(ITestOutputHelper output) { this.output = output; IConfiguration configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var config = new ServerConfig(); configuration.Bind(config); var apiContext = new ApiContext(config.MongoDB); var repoFriend = new FriendRepository(apiContext); //Given friendsController = new FriendsController(repoFriend); }
public async void GetStatus_OnValidQuery_OkRequestWithStatus() { //Arrange var query = "0123456789"; var dto = new ApplicationUser { UserName = query, Status = "I'm mocking you!" }; var persistenceMock = new Mock <IFriendsPersistence>(); persistenceMock .Setup(p => p.Friends.FindByNameAsync(It.IsAny <string>())) .ReturnsAsync(dto); var mapperMock = new Mock <IMapper>(); //Act var controller = new FriendsController(_logger, persistenceMock.Object, mapperMock.Object); var response = await controller.GetStatus(query); //Assert Assert.IsType <OkObjectResult>(response); }
public static void TestSetup(TestContext context) { _repositoryStub = new FriendRepositoryStub(); _sut = new FriendsController(_repositoryStub); }
void OnDestroy() { Debug.Log("FriendsController:OnDestroy()"); if(friendsController != null) { friendsController = null; } }
void Awake() { friendsController = this; GoogleMobileAdsController.Instance.ShowInterstitial(); }
public void TestInitialize() { this.friendsController = new FriendsController(); }
void before_each() { controller = new FriendsController(); SetCurrentUser(controller, GivenUser("*****@*****.**", "@me")); }