public void Setup() { this.RepositoryMock = new Mock <IRepository <Models.Institution> >(); this.UnitOfWorkMock = new Mock <IUnitOfWork>(); this.UnitOfWorkMock.Setup(uow => uow.GetRepository <Models.Institution>()).Returns(this.RepositoryMock.Object); this.Mapper = new Mock <IMapper>(); this.InstController = new InstitutionController(this.UnitOfWorkMock.Object, this.Mapper.Object); }
public void TestDeleteMember() { InstitutionController apiController = new InstitutionController(); List <Member> deleteMembers = apiController.DeleteMember(111).ToList(); List <Member> members = apiController.GetAllMembers().ToList(); Assert.AreEqual(deleteMembers.Count, members.Count); }
private InstitutionController GetInstitutionController(string name) { var options = new DbContextOptionsBuilder <InstitutionContext>() .UseInMemoryDatabase(databaseName: name) .Options; var context = new InstitutionContext(options); var controller = new InstitutionController(context); return(controller); }
public void InstDetailsTest(int id, string name, int count) { var instController = new InstitutionController(_context); var actual = instController.Details(id); var result = Assert.IsType <ViewResult>(actual); var ins = (ShowInstitution)result.ViewData.Model; Assert.Equal(name, ins.Inst.NameInst); Assert.Equal(count, ins.Employees.Count()); }
public void TestUpdateAccountBalance() { InstitutionController apiController = new InstitutionController(); Account newAccountData = new Account { accountId = 1111, balance = 35.43 }; Account updatedAccount = apiController.UpdateAccountBalance(234789, 23456, newAccountData); Assert.AreEqual(newAccountData.balance, updatedAccount.balance); }
public void TestAddInstitution() { InstitutionController apiController = new InstitutionController(); Institution inputInstitution = new Institution { institutionId = 2222, name = "Nikhil Kumar Talla" }; Institution institution = apiController.AddInstitution(inputInstitution); Assert.AreEqual(institution.name, inputInstitution.name); }
private async Task <InstitutionController> GetInstitutionController(string name, Institution institution) { var options = new DbContextOptionsBuilder <InstitutionContext>() .UseInMemoryDatabase(databaseName: name) .Options; var context = new InstitutionContext(options); context.Institutions.Add(institution); await context.SaveChangesAsync(); var controller = new InstitutionController(context); return(controller); }
public void TestAddMember() { InstitutionController apiController = new InstitutionController(); Member inputMember = new Member { memberId = 111, givenName = "Nikhil", surname = "Talla", institutionId = 000, accounts = new List <Account>() { new Account { accountId = 111, balance = 222 } } }; Member member = apiController.AddMember(inputMember); Assert.AreEqual(member.givenName, inputMember.givenName); }
public void TestGetMemberByID() { InstitutionController apiController = new InstitutionController(); Member member = apiController.GetMemberByID(234789); Member expectedMember = new Member { memberId = 234789, givenName = "John", surname = "Doe", institutionId = 78923, accounts = new List <Account>() { new Account { accountId = 23456, balance = 12.50 } } }; Assert.AreEqual(expectedMember.givenName, member.givenName); }
public void TestGetAllMembers() { InstitutionController apiController = new InstitutionController(); List <Member> members = apiController.GetAllMembers().ToList(); List <Member> expectedData = new List <Member>() { new Member { memberId = 234789 , givenName = "John" , surname = "Doe" , institutionId = 78923 , accounts = new List <Account>() { new Account { accountId = 23456, balance = 12.50 } } } }; Assert.AreEqual(expectedData.Count, members.Count); }
public void TestGetAllInstitutions() { InstitutionController apiController = new InstitutionController(); List <Institution> institutions = apiController.GetAllInstitutions().ToList(); List <Institution> expectedData = new List <Institution>() { new Institution { institutionId = 78923, name = "First Credit Union" }, new Institution { institutionId = 78924, name = "Bank of America" }, new Institution { institutionId = 78925, name = "Citi Bank" }, new Institution { institutionId = 2222, name = "Nikhil Kumar Talla" } }; Assert.AreEqual(expectedData.Count, institutions.Count); }
public InstitutionControllerTest() { var institutionRepository = new InstitutionRepository(_options); _controller = new InstitutionController(institutionRepository); }
public InstitutionControllerTests() { _repo = new Mock <IInstitutionRepository>(); _controller = new InstitutionController(_repo.Object); }