public async Task ThrowBetException_IfInvalidFirstOddsValue_Passed() { var options = TestUtils.GetOptions(nameof(ThrowBetException_IfInvalidFirstOddsValue_Passed)); using (var arrangeContext = new BettingContext(options)) { var eventTest = new Event { Id = 1, EventName = "Arsenal - Liverpool", OddsForFirstTeam = 3.2, OddsForDraw = 2.9, OddsForSecondTeam = 1.85, EventStartDate = DateTime.Now }; arrangeContext.Events.Add(eventTest); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new BettingContext(options)) { var sut = new EditModeService(assertContext); var ex = await Assert.ThrowsExceptionAsync <BetException>( async() => await sut.UpdateEvent(1, eventName, "d", oddsForDraw, oddsForSecond, date)); } }
public async Task Return_ValidEventDTO_WhenValidValuesPassed() { var options = TestUtils.GetOptions(nameof(Return_ValidEventDTO_WhenValidValuesPassed)); using (var arrangeContext = new BettingContext(options)) { var eventTest = new Event { Id = 1, EventName = "Arsenal - Liverpool", OddsForFirstTeam = 3.2, OddsForDraw = 2.9, OddsForSecondTeam = 1.85, EventStartDate = DateTime.Now }; arrangeContext.Events.Add(eventTest); await arrangeContext.SaveChangesAsync(); } using (var assertContext = new BettingContext(options)) { var sut = new EditModeService(assertContext); var result = await sut.UpdateEvent(1, eventName, oddsForFirst, oddsForDraw, oddsForSecond, date); Assert.AreEqual(eventName, result.EventName); Assert.AreEqual(1.35, result.OddsForFirstTeam); Assert.AreEqual(3.30, result.OddsForDraw); Assert.AreEqual(6.50, result.OddsForSecondTeam); Assert.IsInstanceOfType(result, typeof(EventDTO)); } }