예제 #1
0
        public void GetContractorByIdOrName()
        {
            Mock<IKindRepository> mock = new Mock<IKindRepository>();
            mock.Setup(a => a.Kinds).Returns(new Kind []
            {
                new Kind { id = 1, name = "Zestawy komputerowe" },
                new Kind { id = 2, name = "Urządzenia wyjścia" },
                new Kind { id = 3, name = "Urządzenia wejścia-wyjścia"} ,
                new Kind { id = 4, name = "Urządzenia transmisji danych"} ,
                new Kind { id = 5, name = "Oprogramowanie komputerów"} ,
            }.AsQueryable());

            KindController ctrl = new KindController(mock.Object);
            Kind temp = ctrl.GetKindById(3);
            Assert.IsNotNull(temp);
            Assert.AreEqual(temp.name, "Urządzenia wejścia-wyjścia");

            temp = ctrl.GetKindById(7);
            Assert.IsNull(temp);

            temp = ctrl.GetKindByName("Urządzenia transmisji danych");
            Assert.IsNotNull(temp);
            Assert.AreEqual(temp.id, 4);

            temp = ctrl.GetKindByName("xxxxxxxxxxxxxxxxxx");
            Assert.IsNull(temp);
        }
예제 #2
0
 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);
 }
예제 #3
0
        public void GetAllKindsAndCount()
        {
            Mock<IKindRepository> mock = new Mock<IKindRepository>();
            mock.Setup(a => a.Kinds).Returns(new Kind[]
            {
                new Kind { id = 1, name = "Zestawy komputerowe" },
                new Kind { id = 2, name = "Urządzenia wyjścia" },
                new Kind { id = 3, name = "Urządzenia wejścia-wyjścia"} ,
                new Kind { id = 4, name = "Urządzenia transmisji danych"} ,
                new Kind { id = 5, name = "Oprogramowanie komputerów"} ,
            }.AsQueryable());

            KindController ctrl = new KindController(mock.Object);
            int count = ctrl.CountKinds();
            Assert.IsNotNull(count);
            Assert.AreEqual(count, 5);

            object[] temp = ctrl.GetAllKinds();
            Assert.AreEqual(temp.Length, 5);
        }