public void TestPeripheralDevices() { Mock<IPeripheralDeviceRepository> mock = new Mock<IPeripheralDeviceRepository>(); mock.Setup(a => a.PeripheralDevices).Returns(new PeripheralDevice[] { new PeripheralDevice { id = 1, name = "jednostka centralna" }, new PeripheralDevice { id = 2, name = "monitor" }, new PeripheralDevice { id = 3, name = "UPS" }, new PeripheralDevice { id = 4, name = "drukarka" }, new PeripheralDevice { id = 5, name = "skaner" }, }.AsQueryable()); PeripheralDeviceController ctrl = new PeripheralDeviceController(mock.Object); int count = ctrl.CountPeripheralDevices(); Assert.IsNotNull(count); Assert.AreEqual(count, 5); PeripheralDevice device = ctrl.GetPeripheralDeviceById(3); Assert.AreEqual(device.name, "UPS"); Assert.IsNotNull(device); device = ctrl.GetPeripheralDeviceById(8); Assert.IsNull(device); device = ctrl.GetPeripheralDeviceByName("skaner"); Assert.IsNotNull(device); Assert.AreEqual(device.id, 5); device = ctrl.GetPeripheralDeviceByName("router"); Assert.IsNull(device); object[] temp = ctrl.GetAllPeripheralDevices(); Assert.AreEqual(temp.Length, 5); Assert.AreEqual(((PeripheralDevice)temp[3]).id, 4); }
private void SetUpControllers() { ContractorController = new ContractorController(ContractorRepository); DeviceController = new DeviceController(DeviceRepository); FixedAssetController = new FixedAssetController(FixedAssetRepository); KindController = new KindController(KindRepository); LicenceController = new LicenceController(LicenceRepository); PeripheralDeviceController = new PeripheralDeviceController(PeripheralDeviceRepository); PersonController = new PersonController(PersonRepository); SectionController = new SectionController(SectionRepository); SubgroupController = new SubgroupController(SubgroupRepository); MembershipRoleController = new MembershipRoleController(MembershipRoleRepository); MembershipUserController = new MembershipUserController(MembershipUserRepository, MembershipRoleController); }