public async Task Get_will_fetch_only_data_for_the_Account() { // Arrange var wowId = Guid.NewGuid(); var wowId2 = Guid.NewGuid(); IRepoAccount repoAccount = createFakeRepoAccount(wowId, wowId2); IRepoUser repoUser = createFakeRepoUser(wowId, wowId2); User mutableAccount = null; Action<User> saveUserToSession = (account) => mutableAccount = account; Func<User> getFromSession = () => mutableAccount; IServiceUser serviceUser = new ServiceUser(repoUser, saveUserToSession, getFromSession); IServiceAccount serviceAccount = new ServiceAccount(repoAccount); serviceUser.authenticate("wow", "wow"); AccountController controller = new AccountController(serviceUser, serviceAccount); // Act var result = await controller.GetAsync(); // Assert Assert.IsNotNull(result); Assert.AreEqual(2, result.Count()); Assert.AreEqual(result.ElementAt(1).Name, "Lor'themar Theron"); }
public async Task Add_Correct_Character_To_Account() { // Arrange var wowId = Guid.NewGuid(); var wowId2 = Guid.NewGuid(); IRepoAccount repoAccount = createFakeRepoAccount(wowId, wowId2); IRepoUser repoUser = createFakeRepoUser(wowId, wowId2); User mutableAccount = null; Action<User> saveUserToSession = (account) => mutableAccount = account; Func<User> getFromSession = () => mutableAccount; IServiceUser serviceUser = new ServiceUser(repoUser, saveUserToSession, getFromSession); IServiceAccount serviceAccount = new ServiceAccount(repoAccount); serviceUser.authenticate("wow", "wow"); AccountController controller = new AccountController(serviceUser, serviceAccount); var cmd = new CreateCharacterCmd() { Id = Guid.NewGuid(), Name = "Orgrim Doomhammer", Class = ClassFactory.Warrior.ToString(), Faction = FactionFactory.Horde.ToString(), Level = 100, Race = RaceFactory.Orc.ToString() }; // Act var result = await controller.AddNewCharacterAsync(cmd); // Assert var response = AssertResponse(result); Assert.IsTrue(response.IsOk); }
public async Task retrieve_empty_guid_character_from_account() { // Arrange var wowId = Guid.NewGuid(); var wowId2 = Guid.NewGuid(); IRepoAccount repoAccount = createFakeRepoAccount(wowId, wowId2); IRepoUser repoUser = createFakeRepoUser(wowId, wowId2); User mutableAccount = null; Action<User> saveUserToSession = (account) => mutableAccount = account; Func<User> getFromSession = () => mutableAccount; IServiceUser serviceUser = new ServiceUser(repoUser, saveUserToSession, getFromSession); IServiceAccount serviceAccount = new ServiceAccount(repoAccount); serviceUser.authenticate("wow", "wow"); AccountController controller = new AccountController(serviceUser, serviceAccount); var cmd = new CreateCharacterCmd() { Id = Guid.NewGuid(), Name = "Orgrim Doomhammer", Class = ClassFactory.Warrior.ToString(), Faction = FactionFactory.Horde.ToString(), Level = 100, Race = RaceFactory.Orc.ToString() }; await controller.AddNewCharacterAsync(cmd); var currentUser = serviceUser.getCurrentUser(); var characters = await serviceAccount.GetCharactersAsync(currentUser.Id); await controller.RemoveCharacterAsync(new RemoveCharacterCmd() { Id = characters.ElementAt(0).Id }); var retrieveCmd = new RetrieveCharacterCmd() { Id = Guid.Empty }; // Act var result = await controller.RetrieveCharacterAsync(retrieveCmd); // Assert var response = AssertResponse(result); Assert.IsFalse(response.IsOk); }
public async Task send_invalid_command_to_create_character(Guid id, string name, string @class, string faction, int level, string race) { // Arrange var wowId = Guid.NewGuid(); var wowId2 = Guid.NewGuid(); IRepoAccount repoAccount = createFakeRepoAccount(wowId, wowId2); IRepoUser repoUser = createFakeRepoUser(wowId, wowId2); User mutableAccount = null; Action<User> saveUserToSession = (account) => mutableAccount = account; Func<User> getFromSession = () => mutableAccount; IServiceUser serviceUser = new ServiceUser(repoUser, saveUserToSession, getFromSession); IServiceAccount serviceAccount = new ServiceAccount(repoAccount); serviceUser.authenticate("wow", "wow"); AccountController controller = new AccountController(serviceUser, serviceAccount); var cmd = new CreateCharacterCmd() { Id = id, Name = name, Class = @class, Faction = faction, Level = level, Race = race }; // Act var result = await controller.AddNewCharacterAsync(cmd); // Assert var response = AssertResponse(result); Assert.IsFalse(response.IsOk); }