コード例 #1
0
        public DeterminationServiceUnitTests()
        {
            builder = new ContainerBuilder();
            builder.RegisterModule <AutofacModule>();
            IEnumerable <DeterminationResult> determinationlists = new List <DeterminationResult>()
            {
                new DeterminationResult {
                    DeterminationID = 1, DeterminationName = "Test1", DeterminationAlias = "T1", ColumnLabel = "Col1"
                },
                new DeterminationResult {
                    DeterminationID = 2, DeterminationName = "Test2", DeterminationAlias = "T2", ColumnLabel = "Col2"
                }
            };

            determinationRequestArgs = new DeterminationRequestArgs
            {
                CropCode   = "TO",
                TestID     = 1,
                TestTypeID = 1
            };

            dataWithMarkerRequestArgs = new Entities.Args.DataWithMarkerRequestArgs
            {
                TestID     = 1,
                PageNumber = 1,
                PageSize   = 100
            };

            materialsWithMarkerRequestArgs = new Entities.Args.MaterialsWithMarkerRequestArgs
            {
                TestID     = 1,
                PageNumber = 1,
                PageSize   = 100
            };
            externalDeterminationRequestArgs = new Entities.Args.ExternalDeterminationRequestArgs
            {
                CropCode   = "TO",
                TestTypeID = 1
            };

            var dataWithMarker = new DataWithMarkerResult
            {
                Data  = new DataTable(),
                Total = 5
            };
            var materialWithMarker = new MaterialsWithMarkerResult
            {
                Total = 5,
                Data  = new DataTable()
            };

            var determinationRepo = A.Fake <IDeterminationRepository>();

            A.CallTo(() => determinationRepo.GetDeterminationsAsync(determinationRequestArgs)).Returns(determinationlists);
            A.CallTo(() => determinationRepo.GetDataWithDeterminationsAsync(dataWithMarkerRequestArgs)).Returns(dataWithMarker);
            A.CallTo(() => determinationRepo.GetMaterialsWithDeterminationsAsync(materialsWithMarkerRequestArgs)).Returns(materialWithMarker);
            A.CallTo(() => determinationRepo.GetDeterminationsForExternalTestsAsync(externalDeterminationRequestArgs)).Returns(determinationlists);
            A.CallTo(() => determinationRepo.GetMaterialsWithDeterminationsForExternalTestAsync(materialsWithMarkerRequestArgs)).Returns(materialWithMarker);

            builder.RegisterInstance(determinationRepo).As <IDeterminationRepository>().SingleInstance();

            var container = builder.Build();

            _determinationService = container.Resolve <IDeterminationService>();
        }
コード例 #2
0
 public Task <IEnumerable <DeterminationResult> > GetDeterminationsForExternalTestsAsync(ExternalDeterminationRequestArgs requestArgs)
 {
     return(DbContext.ExecuteReaderAsync(DataConstants.PR_GET_DETERMINATIONS_FOR_EXTERNAL_TESTS, CommandType.StoredProcedure, args =>
     {
         args.Add("@CropCode", requestArgs.CropCode);
         args.Add("@TestTypeID", requestArgs.TestTypeID);
     }, reader => new DeterminationResult
     {
         DeterminationID = reader.Get <int>(0),
         DeterminationName = reader.Get <string>(1),
         DeterminationAlias = reader.Get <string>(2),
         ColumnLabel = reader.Get <string>(3)
     }));
 }
コード例 #3
0
        public async Task <IHttpActionResult> GetDeterminstaionsForExternalTests([FromUri] ExternalDeterminationRequestArgs requestArgs)
        {
            var determminations = await determinationService.GetDeterminationsForExternalTestsAsync(requestArgs);

            return(Ok(determminations));
        }
コード例 #4
0
 public Task <IEnumerable <DeterminationResult> > GetDeterminationsForExternalTestsAsync(ExternalDeterminationRequestArgs requestArgs)
 {
     requestArgs.Validate();
     return(repository.GetDeterminationsForExternalTestsAsync(requestArgs));
 }