public async Task AddAnalysisAsyncShouldHandleErrorsAsync() { //arrange var options = new DbContextOptionsBuilder <YouTubeJamContext>() .UseInMemoryDatabase("AddAnalysisAsyncShouldHandleErrorsAsync") .Options; using var context = new YouTubeJamContext(options); var mapper = new DBMapper(context); var repo = new Repository(context, mapper); BusinessLogic.Creator b = new BusinessLogic.Creator() { Email = "*****@*****.**", ChannelName = "Mathemartian" }; AverageSentiment avg = new AverageSentiment() { VideoURL = "Abc", AverageSentimentScore = 0.5 }; //act try { await repo.AddAnalysisAsync(avg, b); Assert.True(false); } catch (CreatorDoesNotExistException) { //assert Assert.True(true); } }
public async Task AddAnalysisShouldNotCreateNewCreatorsAsync() { //arrange var options = new DbContextOptionsBuilder <YouTubeJamContext>() .UseInMemoryDatabase("AddAnalysisShouldNotCreateNewCreators") .Options; using var context = new YouTubeJamContext(options); var mapper = new DBMapper(context); var repo = new Repository(context, mapper); BusinessLogic.Creator c = new BusinessLogic.Creator() { FirstName = "Marielle", LastName = "Nolasco", Email = "*****@*****.**" }; AverageSentiment avg = new AverageSentiment() { VideoURL = "Abc", AverageSentimentScore = 0.5 }; //act await repo.AddCreatorAsync(c); await repo.AddChannelAsync(c, "MatheMartian"); await repo.AddVideoAsync("Abc", "MatheMartian"); await repo.AddAnalysisAsync(avg, c); //assert using var assertContext = new YouTubeJamContext(options); mapper = new DBMapper(assertContext); repo = new Repository(assertContext, mapper); var result = await repo.GetCreatorsAsync(); if (result.Count > 1) { Assert.True(false); } else { Assert.True(true); } }
public async Task AddAnalysisAsyncWithLimitedInfoShouldAddAsync() { //arrange var options = new DbContextOptionsBuilder <YouTubeJamContext>() .UseInMemoryDatabase("AddAnalysisAsyncWithLimitedInfoShouldAddAsync") .Options; using var context = new YouTubeJamContext(options); var mapper = new DBMapper(context); var repo = new Repository(context, mapper); BusinessLogic.Creator c = new BusinessLogic.Creator() { FirstName = "Marielle", LastName = "Nolasco", Email = "*****@*****.**" }; BusinessLogic.Creator b = new BusinessLogic.Creator() { Email = "*****@*****.**", ChannelName = "Mathemartian" }; AverageSentiment avg = new AverageSentiment() { VideoURL = "Abc", AverageSentimentScore = 0.5 }; //act await repo.AddCreatorAsync(c); await repo.AddChannelAsync(c, "MatheMartian"); await repo.AddAnalysisAsync(avg, b); //assert using var assertContext = new YouTubeJamContext(options); var rest = await assertContext.Analysis1.FirstAsync(); Assert.NotNull(rest); }
public async Task GetUserHistoryShouldGetSomethingAsync() { //arrange var options = new DbContextOptionsBuilder <YouTubeJamContext>() .UseInMemoryDatabase("GetUserHistoryShouldGetSomething") .Options; using var context = new YouTubeJamContext(options); var mapper = new DBMapper(context); var repo = new Repository(context, mapper); BusinessLogic.Creator c = new BusinessLogic.Creator() { FirstName = "Marielle", LastName = "Nolasco", Email = "*****@*****.**" }; AverageSentiment avg = new AverageSentiment() { VideoURL = "Abc", AverageSentimentScore = 0.5 }; //act await repo.AddCreatorAsync(c); await repo.AddChannelAsync(c, "MatheMartian"); await repo.AddVideoAsync("Abc", "MatheMartian"); await repo.AddAnalysisAsync(avg, c); //assert using var assertContext = new YouTubeJamContext(options); mapper = new DBMapper(assertContext); repo = new Repository(assertContext, mapper); var result = await repo.GetUserSearchHistoryAsync("*****@*****.**"); Assert.NotNull(result[0].VideoURL); }