Пример #1
0
        private JsonResult GetData <TLookup>(LookupController lookupController) where TLookup : MvcLookup
        {
            lookupController.When(sub => sub.GetData(Arg.Any <TLookup>(), filter)).DoNotCallBase();
            lookupController.GetData(Arg.Any <TLookup>(), filter).Returns(new JsonResult("Test"));

            return(lookupController.GetData(null, filter));
        }
Пример #2
0
        public QualificationApiControllertest()
        {
            var serviceProvider = services.BuildServiceProvider();

            tenderService                = serviceProvider.GetService <ITenderAppService>();
            qualificationAppService      = serviceProvider.GetService <IQualificationAppService>();
            iDMAppService                = serviceProvider.GetService <IIDMAppService>();
            lookupAppService             = serviceProvider.GetService <ILookUpService>();
            supplierqualificationService = serviceProvider.GetService <ISupplierQualificationDocumentAppService>();
            verificationService          = serviceProvider.GetService <IVerificationService>();

            //Configure mapping just for this test
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <PreQualificationBasicDetailsModel, PreQualificationBasicDetailsModel>();
                cfg.CreateMap <MOF.Etimad.Monafasat.Core.Entities.Tender, PreQualificationSavingModel>();
                cfg.ValidateInlineMaps = false;
            });

            mapper = config.CreateMapper();

            _mockRootConfiguration = MockHelper.CreateIOptionSnapshotMock(new MOF.Etimad.Monafasat.SharedKernal.RootConfigurations());
            //verificationService = new Mock<IVerificationService>().Object;
            authorizationService = new Mock <IAuthorizationService>().Object;
            supplierService      = new Mock <ISupplierService>().Object;
            offerAppService      = new Mock <IOfferAppService>().Object;
            supplierQualificationDocumentDomainService = new Mock <ISupplierQualificationDocumentDomainService>().Object;
            memoryCache      = new Mock <IMemoryCache>().Object;
            branchAppService = new Mock <IBranchAppService>().Object;

            _qualificationController = new QualificationController(supplierqualificationService, qualificationAppService, mapper, verificationService,
                                                                   iDMAppService, authorizationService, supplierService, offerAppService, lookupAppService, tenderService, supplierQualificationDocumentDomainService, _mockRootConfiguration);

            _lookupController = new LookupController(lookupAppService, mapper, iDMAppService, branchAppService, memoryCache, _mockRootConfiguration);
        }
Пример #3
0
        public LookupControllerTests()
        {
            unitOfWork = Substitute.For <IUnitOfWork>();
            controller = Substitute.ForPartsOf <LookupController>(unitOfWork);

            lookup = Substitute.For <MvcLookup>();
            filter = new LookupFilter();
        }
        private JsonResult GetData <TLookup>(LookupController lookupController) where TLookup : ALookup
        {
            JsonResult result = new JsonResult("Test");

            lookupController.GetData(Arg.Any <TLookup>(), filter).Returns(result);
            lookupController.When(sub => sub.GetData(Arg.Any <TLookup>(), filter)).DoNotCallBase();

            return(result);
        }
Пример #5
0
        public void GetCatgoriesTest()
        {
            // Arrange
            LookupController controller = new LookupController();

            // Act
            IHttpActionResult result = controller.GetCategories();

            // Assert
            Assert.IsNotNull(result);
        }
Пример #6
0
        public async Task should_return_results()
        {
            var ctrl = new LookupController(_fakeLog, _fakeConfig);
            var req  = new LookUpRequest
            {
                Address = "calebukle.com",
            };

            var actual = await ctrl.RunTasks(req);

            Assert.IsInstanceOf <OkObjectResult>(actual);
        }
Пример #7
0
        public async Task GetReductionReasons_ReturnsData()
        {
            var _agencyCode = "022001000000";
            _claims = new Claim[2] {
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetReductionReasons();

            Assert.NotNull(result);
            Assert.IsType<List<LookupModel>>(result);
        }
Пример #8
0
        public async Task GetAllBuyerSuppliers_ReturnsData()
        {
            var _tenderId = 1;
            _claims = new Claim[1] {
                new Claim(IdentityConfigs.Claims.Role, RoleNames.AdminAndAccountManagerPolicy)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetAllBuyerSuppliers(_tenderId);

            Assert.NotNull(result);
            Assert.IsType<List<LookupModel>>(result);
            Assert.NotEmpty(result);
        }
Пример #9
0
        public async Task GetBranchAddressTypesAndCommitteesByAgency_ReturnsData()
        {
            var _agencyCode = "022001000000";
            _claims = new Claim[2] {
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetBranchAddressTypesAndCommitteesByAgency();

            Assert.NotNull(result);
            Assert.IsType<BranchModel>(result);
            Assert.NotEmpty(result.BranchAddressTypes);
        }
Пример #10
0
        public void Setup()
        {
            _cuisinesDataSetup = new List <LookupRestaurantType>
            {
                new LookupRestaurantType {
                    Id = 1, Type = "American"
                }
            };


            _lookupTaskMock = new Mock <ILookupTask>();
            _lookupTaskMock.Setup(p => p.GetCuisines()).Returns(_cuisinesDataSetup);

            _mappingService   = new MappingService();
            _lookupController = new LookupController(_lookupTaskMock.Object, _mappingService);
        }
Пример #11
0
        public async Task GetWebsiteTypesReturnsValidResponse()
        {
            using (var context = SqlLiteInMemory.GetTestContext())
            {
                context.SeedDbWebsiteTypes();
                var lookupController = new LookupController(context);

                var result = await lookupController.GetWebsiteTypes();

                Assert.That(result, Is.InstanceOf(typeof(OkObjectResult)));
                var ok = (OkObjectResult)result;
                Assert.That(ok.Value, Is.InstanceOf(typeof(List <WebsiteType>)));
                var listResult = (List <WebsiteType>)ok.Value;
                Assert.AreEqual(4, listResult.Count);
            }
        }
Пример #12
0
        public async Task GetUserBasedOnlistOfRoleIds_ReturnsData()
        {
            var _lstOfRoles = new List<int>() { };
            var _agencyCode = "022001000000";
            _claims = new Claim[2] {
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetUserBasedOnlistOfRoleIds(_lstOfRoles);

            Assert.NotNull(result);
            Assert.IsType<List<UserLookupModel>>(result);
            Assert.Empty(result);
        }
Пример #13
0
        public async Task GetUsersByRoleName_ReturnsData()
        {
            var _roleName = "";
            var _agencyCode = "022001000000";
            _claims = new Claim[2] {
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetUsersByRoleName(_roleName);

            Assert.NotNull(result);
            Assert.IsType<List<UserLookupModel>>(result);
            Assert.Empty(result);
        }
Пример #14
0
        public async Task GetAllDataEntryUsersAsyncTest()
        {
            _claims = new Claim[1] {
                new Claim(IdentityConfigs.Claims.SelectedGovAgency, "022001000000,022001000000")
            };
            _lookupController = _lookupController.WithIdentity(_claims);
            List <int> ids = new List <int>()
            {
                1, 2, 3
            };

            var response = await _lookupController.GetUserBasedOnlistOfRoleIds(ids);

            Assert.NotNull(response);
            Assert.NotEmpty(response);
        }
Пример #15
0
        public async Task GetTechnicalCommitteeList_ReturnsData()
        {
            var _agencyCode = "022001000000";
            var _userId = "1";
            _claims = new Claim[3] {
                new Claim(IdentityConfigs.Claims.NameIdentifier , _userId),
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetTechnicalCommitteeList();

            Assert.NotNull(result);
            Assert.IsType<List<LookupModel>>(result);
            Assert.NotEmpty(result);
        }
Пример #16
0
        public void should_Get()
        {
            // Arrange
            Assert.That(_testLookups, Is.Not.Empty);
            List <int> ids        = _testLookups.Select(x => x.Id).ToList();
            var        controller = new LookupController(_LookupService);

            // Act
            var lookups = controller.Get().Where(x => ids.Contains(x.Id));

            // Assert
            Assert.That(lookups, Is.Not.Empty);
            foreach (var lookup in lookups)
            {
                Debug.Print(lookup.ToString());
            }
        }
        public void FetchAllAgencies_Returns_Deleted()
        {
            //   Arrange
            SetUpAgencyMock();

            var p = new LookupController(_mockContext.Object);

            //  Act
            //var actionResult = p.GetJobTypesOData();
            //var contentResult = actionResult as OkNegotiatedContentResult<List<JobType>>;

            dynamic actionResult = p.FetchAllAgencies(true);
            dynamic content      = actionResult.Content;

            // Assert
            Assert.AreEqual(5, content.items.Count);
        }
Пример #18
0
        public async Task GetAllBranchesNotAssignedToCommittee_ReturnsData()
        {
            var _committeeId = 1;
            var _committeType = 1;
            var _agencyCode = "022001000000";
            _claims = new Claim[2] {
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetAllBranchesNotAssignedToCommittee(_committeeId, _committeType);

            Assert.NotNull(result);
            Assert.IsType<List<LookupModel>>(result);
            Assert.NotEmpty(result);
        }
Пример #19
0
        public LookupApiControllerTest()
        {
            var serviceProvider = services.BuildServiceProvider();
            lookUpService = serviceProvider.GetService<ILookUpService>();
            var config = new MapperConfiguration(cfg =>
            {

                //cfg.CreateMap<SupplierSpecificationModel, SupplierSpecificationAttachment>();
                cfg.ValidateInlineMaps = false;
            });
            mapper = config.CreateMapper();
            iDMAppService = serviceProvider.GetService<IIDMAppService>();
            branchAppService = serviceProvider.GetService<IBranchAppService>();
            memoryCache = serviceProvider.GetService<IMemoryCache>();
            rootConfigurationsMock = SetupConfigurations.GetApplicationConfiguration(Directory.GetCurrentDirectory());
            _lookupController = new LookupController(lookUpService, mapper, iDMAppService, branchAppService, memoryCache, rootConfigurationsMock.Object);
        }
Пример #20
0
        public async Task GetAllCommittesByAgency_ReturnsData()
        {
            var _agencyCode = "022001000000";
            _claims = new Claim[2] {
                new Claim(IdentityConfigs.Claims.isSemiGovAgency, "1"),
                new Claim(IdentityConfigs.Claims.SelectedCR, _agencyCode)
            };
            _lookupController = _lookupController.WithIdentity(_claims);

            var result = await _lookupController.GetAllCommittesByAgency();

            Assert.NotNull(result);
            Assert.IsType<CommitteesModel>(result);
            Assert.NotEmpty(result.CheckCommittees);
            Assert.NotEmpty(result.OpenCommittees);
            Assert.NotEmpty(result.preQualificationCommittees);
            Assert.NotEmpty(result.purchaseCommittees);
            Assert.NotEmpty(result.TechnicalCommittees);
            Assert.Empty(result.VROCommittee);
        }
        public void FetchAllAgencies_DoesNot_Return_Deleted()
        {
            //   Arrange
            //SetUpAgencyMock();
            SetUpMock <Agency>(_queryAgencyList);

            _mockContext.Setup(c => c.Agencies).Returns(mockSet.Object);

            var p = new LookupController(_mockContext.Object);

            //  Act
            //var actionResult = p.GetJobTypesOData();
            //var contentResult = actionResult as OkNegotiatedContentResult<List<JobType>>;

            dynamic actionResult = p.FetchAllAgencies();
            dynamic content      = actionResult.Content;

            // Assert
            Assert.AreEqual(4, content.items.Count);
        }
Пример #22
0
    public static List <LookupValues> LookupRequest(string type)
    {
        LookupController lookupController = new LookupController();

        List <LookupValues> resilts = lookupController.getValues(type);

        if (resilts.Count < 1)
        {
            //throw new Exception("Database error retrieving the lookup table for " + type);
            resilts.Add(new LookupValues()
            {
                Id          = -1,
                Description = "Database error retrieving the lookup table for " + type
            });
            return(resilts);
        }
        else
        {
            return(resilts);
        }
    }
Пример #23
0
 public FrmLookups(LookupController lookupController)
 {
     LookupController = lookupController;
     InitializeComponent();
     BuildList();
 }