Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do GetTax Unit Test #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -39,6 +40,16 @@ public async Task AddTax_InvalidInput_ReturnsToSameActionWithValidation()
public async Task GetTax_ValidData_ReturnsViewResults()
{
// TODO try to stub all dependencies inside GetTax Action inside Tax Controller :)
var userManger = Substitute.For<UserManager<ApplicationUser>>(Substitute.For<IUserStore<ApplicationUser>>(), null, null, null, null, null, null, null, null);
var logger = Substitute.For<ILogger<TaxController>>();
var userTaxRepo = Substitute.For<IUserTaxRepository>();
var taxService = Substitute.For<ITaxService>();
var taxController = new TaxController(userManger, logger, userTaxRepo, taxService);
var result = Assert.ThrowsAsync<ApplicationException>(() => taxController.GetTax(null));

Assert.Equal("Year must be provided", result.Result.Message);
Assert.IsNotType<LocalRedirectResult>(result);
Assert.IsNotType<ViewResult>(result);
}
}
}