Ejemplo n.º 1
0
        public void GivenDeviceTypeShouldReturnAllDeviceOfType()
        {
            var data = new List <Device>
            {
                new Device()
                {
                    Id = 0, Name = "A", DeviceTypeId = 0
                },
                new Device()
                {
                    Id = 1, Name = "B", DeviceTypeId = 1
                },
                new Device()
                {
                    Id = 2, Name = "C", DeviceTypeId = 0
                }
            }.AsQueryable();

            var mockContext = new Mock <UserDataContext>();
            var mockSet     = SetupDbSet(data);

            mockContext.Setup(c => c.Device).Returns(mockSet.Object);

            var dao     = new DeviceDAO(mockContext.Object);
            var results = dao.GetAllDevicesOfType(new DeviceType()
            {
                Id = 0
            });

            Assert.AreEqual(2, results.Count);
            Assert.AreEqual("A", results[0].Name);
            Assert.AreEqual("C", results[1].Name);
        }