Ejemplo n.º 1
0
        public void GetAllTables_ValidExample()
        {
            //Arrange List of Categories
            var Tables = new List <MoqTable>();

            var f1 = new MoqTable(1, 1, "Po lewej");
            var f2 = new MoqTable(2, 2, "Po środku");
            var f3 = new MoqTable(3, 3, "Po prawej");

            Tables.Add(f1);
            Tables.Add(f2);
            Tables.Add(f3);

            var mock = new Mock <IManagerDataAccess>();

            mock.Setup(m => m.GetTables()).Returns(Tables);

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var ReturnedTables     = BarDataModel.GetAllTables();
            var ReturnedTablesCast = ReturnedTables.Cast <MoqTable>().ToList();

            //Asserts
            Assert.IsNotNull(ReturnedTables);

            Assert.AreEqual(ReturnedTablesCast[0].Id, f1.Id);
            Assert.AreEqual(ReturnedTablesCast[0].Number, f1.Number);
            Assert.AreEqual(ReturnedTablesCast[0].Description, f1.Description);

            Assert.AreEqual(ReturnedTablesCast[1].Id, f2.Id);
            Assert.AreEqual(ReturnedTablesCast[1].Number, f2.Number);
            Assert.AreEqual(ReturnedTablesCast[1].Description, f2.Description);

            Assert.AreEqual(ReturnedTablesCast[2].Id, f3.Id);
            Assert.AreEqual(ReturnedTablesCast[2].Number, f3.Number);
            Assert.AreEqual(ReturnedTablesCast[2].Description, f3.Description);
        }
Ejemplo n.º 2
0
        public void GetAllTables_ValidExample()
        {
            //Arrange List of Categories
            var Tables = new List<MoqTable>();

            var f1 = new MoqTable(1, 1, "Po lewej");
            var f2 = new MoqTable(2, 2, "Po środku");
            var f3 = new MoqTable(3, 3, "Po prawej");

            Tables.Add(f1);
            Tables.Add(f2);
            Tables.Add(f3);

            var mock = new Mock<IManagerDataAccess>();
            mock.Setup(m => m.GetTables()).Returns(Tables);

            //Arrange Bar Data Model
            var BarDataModel = new BarDataModel(mock.Object);

            //Act
            var ReturnedTables = BarDataModel.GetAllTables();
            var ReturnedTablesCast = ReturnedTables.Cast<MoqTable>().ToList();

            //Asserts
            Assert.IsNotNull(ReturnedTables);

            Assert.AreEqual(ReturnedTablesCast[0].Id, f1.Id);
            Assert.AreEqual(ReturnedTablesCast[0].Number, f1.Number);
            Assert.AreEqual(ReturnedTablesCast[0].Description, f1.Description);

            Assert.AreEqual(ReturnedTablesCast[1].Id, f2.Id);
            Assert.AreEqual(ReturnedTablesCast[1].Number, f2.Number);
            Assert.AreEqual(ReturnedTablesCast[1].Description, f2.Description);

            Assert.AreEqual(ReturnedTablesCast[2].Id, f3.Id);
            Assert.AreEqual(ReturnedTablesCast[2].Number, f3.Number);
            Assert.AreEqual(ReturnedTablesCast[2].Description, f3.Description);
        }