public async Task GetByUsername_201_Code() { using (var context = InMemoryDatabaseHelper.CreateContext(nameof(GetByUsername_201_Code))) { InMemoryDatabaseHelper.Save(new List <User> { UserSeed.CreateSpecificUser(UserSeed.Id) }, context); var controller = CreateUserControllerObject(context); var actionResult = await controller.GetByUsername(UserSeed.Username); Assert.IsType <ActionResult <UserFindDto> >(actionResult); Assert.Equal(actionResult.Value.Username, UserSeed.Username); Assert.True(actionResult.Value.Id == UserSeed.Id); } }
public async Task Get_Id_201_Code() { var id = Guid.NewGuid().ToString(); using (var context = InMemoryDatabaseHelper.CreateContext(nameof(Get_Id_201_Code))) { InMemoryDatabaseHelper.Save(new List <User> { UserSeed.CreateSpecificUser(id) }, context); var controller = CreateUserControllerObject(context); var actionResult = await controller.Get(id); // Assert Assert.IsType <ActionResult <UserFindDto> >(actionResult); Assert.IsType <UserFindDto>(actionResult.Value); Assert.True(actionResult.Value.Id == id); } using (var context = InMemoryDatabaseHelper.CreateContext(nameof(Get_Id_201_Code))) { Assert.True(context.User.Any(u => u.Id == id)); } }