public IEnumerator GetEnumerator() { var options = CreateNewContextOptions(); WithdrawalMethod courierMethod; WithdrawalMethod creditCardMethod; User user; using (var db = new EntireMoneyProcessingContext(options)) { ProcessingTestHelper.PopulateDefaultMoneyCtx(db); courierMethod = db.Set <WithdrawalMethod>().First(it => it.Code == "courier".ToUpper()); creditCardMethod = db.Set <WithdrawalMethod>().First(it => it.Code == "creditCard".ToUpper()); user = db.Set <User>().First(it => it.UserName == "Andrew"); } var obj1 = new TestComplexObject { WithdrawalMethod = courierMethod, User = user, WithdrawalBefore = DateTime.Now.AddDays(15), Amount = 100M, Comment = "MyComment" }; var obj2 = new TestComplexObject { WithdrawalMethod = creditCardMethod, User = user, WithdrawalBefore = DateTime.Now.AddDays(15), Amount = 100M, Comment = "MyComment" }; yield return (new TestCaseData(options, obj1).SetName("CreateApplication: " + JsonConvert.SerializeObject(obj1).Replace('.', ','))); yield return (new TestCaseData(options, obj2).SetName("CreateApplication: " + JsonConvert.SerializeObject(obj2).Replace('.', ','))); }
public void CreateApplication2(DbContextOptions <EntireMoneyProcessingContext> options, TestComplexObject obj) { try { WithdrawalApplication result = null; using (var db = new EntireMoneyProcessingContext(options)) { var repository = new WithdrawalProcessing(db); Assert.DoesNotThrow( () => result = repository.CreateApplication(obj.WithdrawalMethod, obj.User, obj.WithdrawalBefore, obj.Amount, obj.Comment)); Assert.True(result != null && result.Id > 0); } } catch (Exception ex) { LogEventManager.Logger.Error(ex.Message, ex); throw; } }