Example #1
0
        public void Can_Create_Addresses()
        {
            // Arrange
             // - create the mock repository
             Mock<IClientRepository> mock = new Mock<IClientRepository>();
             mock.Setup(m => m.Clients).Returns(new Client[] {
            new Client {ClientId = 1, ContractNumber = "C1", Address = "Ukrain"},
            new Client {ClientId = 2, ContractNumber = "C2", Address = "Russia"},
            new Client {ClientId = 3, ContractNumber = "C3", Address = "American"},
            new Client {ClientId = 4, ContractNumber = "C4", Address = "Ukrain"},
            new Client {ClientId = 5, ContractNumber = "C5", Address = "Russia"}
            }.AsQueryable());

             // Arrange - create the controller
             NavController target = new NavController(mock.Object);

             // Act = get the set of categories
             string[] results = ((IEnumerable<string>)target.Menu().Model).ToArray();

             // Assert
             Assert.AreEqual(results.Length, 3);
             Assert.AreEqual(results[0], "American");
             Assert.AreEqual(results[1], "Russia");
             Assert.AreEqual(results[2], "Ukrain");
        }
Example #2
0
        public void Indicates_Selected_Address()
        {
            // Arrange
             // - create the mock repository
             Mock<IClientRepository> mock = new Mock<IClientRepository>();
             mock.Setup(m => m.Clients).Returns(new Client[] {
            new Client {ClientId = 1, ContractNumber = "C1", Address = "Ukrain"},
            new Client {ClientId = 2, ContractNumber = "C2", Address = "Russia"},
              }.AsQueryable());

             // Arrange - create the controller
             NavController target = new NavController(mock.Object);

             // Arrange - define the category to selected
             string addressToSelect = "Russia";

             // Action
             string result = target.Menu(addressToSelect).ViewBag.SelectedAddress;

             // Assert
             Assert.AreEqual(addressToSelect, result);
        }