public async void GetWithParameterFiltersAndReturnsExactlyOneCashAccount() { Cashact = new Faker <CashAccount>() .RuleFor(c => c.Incomes, Income) .RuleFor(c => c.Expenses, Expense) .RuleFor(c => c.AccountBalance, x => x.Random.Decimal(3m, 2430m)) .RuleFor(c => c.AccountName, "Abel Rosnovski") .RuleFor(c => c.IsActivated, true) .RuleFor(i => i.CashAccountId, x => x.Random.Guid()) .RuleFor(c => c.CreatedDate, DateTimeOffset.UtcNow) .Generate(); var Cashact1 = new Faker <CashAccount>() .RuleFor(c => c.Incomes, Income) .RuleFor(c => c.Expenses, Expense) .RuleFor(c => c.AccountBalance, x => x.Random.Decimal(3m, 2430m)) .RuleFor(c => c.AccountName, "Yakubu Shloniq") .RuleFor(c => c.IsActivated, true) .RuleFor(i => i.CashAccountId, x => x.Random.Guid()) .RuleFor(c => c.CreatedDate, DateTimeOffset.UtcNow) .Generate(); using (var db = new ItsomContext(CtxOpt)) { db.Database.EnsureCreated(); db.CashAccounts.Add(Cashact); db.CashAccounts.Add(Cashact1); db.SaveChanges(); ICashAccountDataService repo = new CashAccountDataService(db); var controller = new CashAccountsController(repo, Conditions, db); var result = await controller.Get("Abel Rosnovski"); Assert.NotNull(result); var viewResult = Assert.IsType <OkObjectResult>(result); Assert.Equal(200, viewResult.StatusCode); var acct = viewResult.Value as CashAccountDetailModel; Assert.Equal("Abel Rosnovski", acct.AccountName); } }
public async void GetReturnsActionResultWithCashAccountEnumerable() { using (var db = new ItsomContext(CtxOpt)) { db.Database.EnsureCreated(); db.CashAccounts.Add(Cashact); db.SaveChanges(); ICashAccountDataService repo = new CashAccountDataService(db); var controller = new CashAccountsController(repo, Conditions, db); //Act var result = await controller.Get(); //Assert var viewResult = Assert.IsType <OkObjectResult>(result); Assert.Equal(200, viewResult.StatusCode); Assert.IsAssignableFrom <IEnumerable <CashAccountModel> >((IEnumerable <CashAccountModel>)viewResult.Value); } }