public void SaveAvatarStreamAsync_ThrowsExceptionIfStreamIsTooLarge() { var context = GetContext(); try { AvatarInDbRepository repo = new AvatarInDbRepository(context); Stream stream = new MemoryStream(new byte[40_000]);
public void GetAvatarStreamAsync_ReturnsStreamIfAvatarExists() { var context = GetContext(); try { AvatarInDbRepository repo = new AvatarInDbRepository(context); var avatar = repo.GetAvatarStreamAsync("421cb65f-a76d-4a73-8a1a-d792f37ef992").Result; Assert.NotNull(avatar); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }
public void GetAvatarStreamAsync_ThrowsNotFoundResponseExceptionIfAvatarDoesntExist() { var context = GetContext(); try { AvatarInDbRepository repo = new AvatarInDbRepository(context); //var avatar = repo.GetAvatarStreamAsync("421cb65f-a76d-4a73-8a1a-d792f37ef992").Result; Assert.ThrowsAsync <NotFoundResponseException>(async() => await repo.GetAvatarStreamAsync("no-user")).Wait(); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }
public void SaveAvatarStreamAsync_CreatesNewStreamIfAvatarDoesntExist() { var context = GetContext(); try { AvatarInDbRepository repo = new AvatarInDbRepository(context); Stream stream = new MemoryStream(new byte[300]); repo.SaveAvatarStreamAsync("2138b181-4cee-4b85-9f16-18df308f387d", stream).Wait(); var a = repo.GetAvatarStreamAsync("2138b181-4cee-4b85-9f16-18df308f387d").Result; Assert.Equal(300, a.Length); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }
public void SaveAvatarStreamAsync_UpdatesStreamIfAvatarExists() { var context = GetContext(); try { AvatarInDbRepository repo = new AvatarInDbRepository(context); Stream stream = new MemoryStream(new byte[200]); repo.SaveAvatarStreamAsync("421cb65f-a76d-4a73-8a1a-d792f37ef992", stream).Wait(); var a = repo.GetAvatarStreamAsync("421cb65f-a76d-4a73-8a1a-d792f37ef992").Result; Assert.Equal(200, a.Length); } finally { context.Database.EnsureDeleted(); context.Dispose(); } }