public void GetBranch_Should_ReturnBranchDto_When_BranchIsFound() { var okResult = _sut.GetBranch(1).Result as OkObjectResult; Assert.IsNotNull(okResult); Assert.IsInstanceOfType(okResult.Value, typeof(BranchDto)); var branchDto = okResult.Value as BranchDto; Assert.IsNotNull(branchDto); Assert.AreEqual(_firstBranch.Id, branchDto.Id); Assert.AreEqual(_firstBranch.BranchCode, branchDto.BranchCode); Assert.AreEqual(_firstBranch.BranchAddress.Id, branchDto.BranchAddress.Id); Assert.AreEqual(_firstBranch.BranchAddress.Country, branchDto.BranchAddress.Country); Assert.AreEqual(_firstBranch.BranchAddress.City, branchDto.BranchAddress.City); Assert.AreEqual(_firstBranch.BranchAddress.Street, branchDto.BranchAddress.Street); Assert.AreEqual(_firstBranch.BranchAddress.HouseNumber, branchDto.BranchAddress.HouseNumber); Assert.AreEqual(_firstBranch.BranchAddress.ApartmentNumber, branchDto.BranchAddress.ApartmentNumber); Assert.AreEqual(_firstBranch.BranchAddress.PostalCode, branchDto.BranchAddress.PostalCode); }
public void BranchesController_GetBranch_NotFound() { // Arrange var controller = new BranchesController(repo); var branchNumber = 999; // Act var result = controller.GetBranch(branchNumber); // Assert Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public void TestMethodGet() { var context = new TestBankDBContext(); context.Branches.Add(GetSingleItem()); var controller = new BranchesController(context); var result = controller.GetBranch(1) as OkNegotiatedContentResult <Branch>; Assert.IsNotNull(result); Assert.AreEqual(1, result.Content.Id); }
public void BranchesController_GetBranch_OK() { // Arrange var controller = new BranchesController(repo); var branchNumber = 102; // Act var result = controller.GetBranch(branchNumber) as OkNegotiatedContentResult <Branch>; // Assert Assert.IsNotNull(result, "Controller returned null data"); Assert.AreEqual(repo.GetBranchByNumber(branchNumber).Name, result.Content.Name); }