public async Task ApplyEditForApprovalCreatesNewMediaEdit() { // Arrange var inputModel = new MediaDetailsInputModel() { Title = "Daa", Overview = "fiwejfoiwejfoiwj", Language = "en", Id = "1", ReleaseDate = DateTime.Now, Runtime = 100, Budget = 1000, YoutubeTrailerUrl = "www.youtube.com", Keywords = "keywords", Genres = "Adventure, Action", MediaType = "Movie", PosterPath = "/yes.jpg", }; var mock = this.GetMock <MediaEdit>(new List <MediaEdit>()); var expectedCount = 1; var service = new MediaEditService(mock.Object); // Act await service.ApplyEditForApproval(inputModel, "1", ""); var newEdit = mock.Object.All().FirstOrDefault(); // Assert Assert.Equal(expectedCount, mock.Object.All().Count()); Assert.Equal(inputModel.Title, newEdit.Title); Assert.Equal(inputModel.Runtime, newEdit.Runtime); Assert.Equal(inputModel.Keywords, newEdit.KeywordsJson); Assert.Equal(inputModel.PosterPath, newEdit.PosterPath); }
public async Task GetEditForApprovalThrowsExceptionIfItDoesNotExist() { // Arrange var list = this.GetMediaEdits(); var mock = this.GetMock <MediaEdit>(list); var service = new MediaEditService(mock.Object); // Act / Assert await Assert.ThrowsAsync <Exception>(() => service.GetEditForApproval <MediaDetailsInputModel>("weghuweuoighowehg")); }
public async Task RejectEditsDeletesEdit() { // Arrange var list = this.GetMediaEdits(); var expectedEdit = list.LastOrDefault(); var mock = this.GetDeletableMock(list); var service = new MediaEditService(mock.Object); // Act await service.RejectEdit(expectedEdit.Id); // Assert Assert.True(expectedEdit.IsDeleted); }
public async Task GetEditsForApprovalGivesCorrectCount() { // Arrange var list = this.GetMediaEdits(); var expectedCount = list.Count; var mock = this.GetMock <MediaEdit>(list); var service = new MediaEditService(mock.Object); // Act var result = await service.GetEditsForApprovalCount(); // Assert Assert.Equal(expectedCount, result); }
public async Task GetEditForApprovalGetsProperEdit() { // Arrange var list = this.GetMediaEdits(); var expectedEdit = list.FirstOrDefault(); var mock = this.GetMock <MediaEdit>(list); var service = new MediaEditService(mock.Object); // Act var result = await service.GetEditForApproval <MediaDetailsInputModel>(expectedEdit.Id); // Assert Assert.Equal(expectedEdit.Title, result.Title); Assert.Equal(expectedEdit.KeywordsJson, result.Keywords); Assert.Equal(expectedEdit.PosterPath, result.PosterPath); Assert.Equal(expectedEdit.MediaType, result.MediaType); Assert.Equal(expectedEdit.Genres, result.Genres); }
public async Task GetAndApproveEditApprovesThenDeletesEditAndReturnsProperModel() { // Arrange var list = this.GetMediaEdits(); var expectedEdit = list.LastOrDefault(); var mock = this.GetDeletableMock(list); var service = new MediaEditService(mock.Object); // Act var result = await service.GetAndApproveEdit <MediaDetailsInputModel>(expectedEdit.Id); // Assert Assert.True(expectedEdit.IsDeleted); Assert.True(expectedEdit.IsApproved); Assert.Equal(expectedEdit.Title, result.Title); Assert.Equal(expectedEdit.PosterPath, result.PosterPath); Assert.Equal(expectedEdit.Overview, result.Overview); }
public async Task GetEditsForApprovalGetsProperEdits() { // Arrange var list = this.GetMediaEdits(); var expectedCount = list.Count; var mock = this.GetMock <MediaEdit>(list); var service = new MediaEditService(mock.Object); // Act var result = await service.GetEditsForApproval <MediaDetailsInputModel>(1, 10); // Assert var listTitles = list.Select(x => x.Title).ToList(); var resultTitle = result.Select(x => x.Title).ToList(); Assert.Equal(expectedCount, result.Count()); Assert.True(listTitles.SequenceEqual(resultTitle)); }