public async Task Authenticate_With_Valid_Should_Ok() { // Arrange var authenticationService = new AuthenticationService(await ContextGenerator.GetDummyContext()); // Act var user = authenticationService.Authenticate("admin", "admin"); // Assert Assert.Equal("admin", user.UserName); }
public async Task Authenticate_InvalidUser_Should_Null() { // Arrange var authenticationService = new AuthenticationService(await ContextGenerator.GetDummyContext()); // Act var user = authenticationService.Authenticate("JohnDoe", "admin"); // Assert Assert.Null(user); }
public async Task GetContent_ShouldNull_NotExistingData_WhenNoResizing() { // Arrange var storageProviderMock = new Mock <IStorageProvider>(); storageProviderMock.Setup(x => x.Get(It.IsAny <string>())).Returns((byte[])null); var pictureService = new PictureService(await ContextGenerator.GetDummyContext(), storageProviderMock.Object); // Act var data = pictureService.GetContent(Guid.NewGuid()); // Assert Assert.Null(data); }
public async Task SavePicture_ShouldSave() { // Arrange var database = await ContextGenerator.GetDummyContext(); var user = database.Users.First(); var picture = Files.GetSimpleImage(); var pictureFileName = "test.jpg"; var pictureService = await GetPictureService(database); // Act var pictureId = pictureService.SavePicture(user.Id, pictureFileName, picture); // Assert Assert.NotEqual(default, pictureId);
public async Task GetContent_ShouldReturn_ExistingData() { // Arrange var existing = Files.GetSimpleImage(); var existingId = Guid.NewGuid(); var storageProviderMock = new Mock <IStorageProvider>(); storageProviderMock.Setup(x => x.Get($"{existingId}-50-40")).Returns(existing); var pictureService = new PictureService(await ContextGenerator.GetDummyContext(), storageProviderMock.Object); // Act var data = pictureService.GetContent(existingId, 50, 40); // Assert Assert.Equal(existing, data); }
public async Task GetContent_NotFound_ShouldNull() { // Arrange var database = await ContextGenerator.GetDummyContext(); var pictureService = await GetPictureService(database); var pictureId = Guid.NewGuid(); var userId = database.Users.First(x => x.UserName == "admin").Id; // Act var picture = pictureService.Get(userId, pictureId); // Assert Assert.Null(picture); }
public async Task GetContent_Unauthorized_ShouldNull() { // Arrange var database = await ContextGenerator.GetDummyContext(); var pictureService = await GetPictureService(database); var pictureId = database.Pictures.First().Id; var userId = database.Users.First(x => x.UserName == "user").Id; // Act var picture = pictureService.Get(userId, pictureId); // Assert Assert.Null(picture); }
public async Task GetContent_Happy_Flow() { // Arrange var database = await ContextGenerator.GetDummyContext(); var pictureService = await GetPictureService(database); var pictureId = database.Pictures.First().Id; var userId = database.Users.First(x => x.UserName == "admin").Id; // Act var picture = pictureService.Get(userId, pictureId); // Assert Assert.NotNull(picture); Assert.Equal(pictureId, picture.Id); }