示例#1
0
        public void GenerateBlock(int frequency)
        {
            var block = BlockSelecter.GenerateBlock(frequency);

            block.Should().HaveCount(2 * 5 * frequency);

            var numSamples = block.Where(x => x == true).Count();

            numSamples.Should().Be(10);
        }
        public void GetSamplerBySampleGroupCode_STR_MockedDS(string method)
        {
            var stCode     = "00";
            var sgCode     = "01";
            var freq       = 5;
            var iFreq      = 2;
            var blockState = new String(BlockSelecter.GenerateBlock(freq).Select(x => x ? '-' : 'x').ToArray());

            var sInfo = new SamplerInfo()
            {
                SamplingFrequency  = freq,
                InsuranceFrequency = iFreq,
                SampleGroupCode    = sgCode,
                StratumCode        = stCode,
                Method             = method,
            };

            var sState = new SamplerState()
            {
                SampleGroupCode    = sgCode,
                StratumCode        = stCode,
                SampleSelectorType = nameof(BlockSelecter),
                BlockState         = blockState,
            };

            var mockSids = new Mock <ISamplerInfoDataservice>();

            mockSids.Setup(x => x.GetSamplerInfo(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(sInfo);
            mockSids.Setup(x => x.GetSamplerState(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(sState);

            var ssRepo = new SampleSelectorRepository(mockSids.Object);

            var sampler = ssRepo.GetSamplerBySampleGroupCode(stCode, sgCode);

            sampler.Should().NotBeNull();

            sampler.StratumCode.Should().Be(stCode);
            sampler.SampleGroupCode.Should().Be(sgCode);

            sampler.Should().BeAssignableTo <IFrequencyBasedSelecter>();

            var freqSampler = sampler as IFrequencyBasedSelecter;

            freqSampler.Frequency.Should().Be(freq);
            freqSampler.Sample().Should().NotBeNull();

            var samplerAgain = ssRepo.GetSamplerBySampleGroupCode(stCode, sgCode);

            samplerAgain.Should().BeSameAs(sampler);
        }
示例#3
0
        public void TestBlockSelector_2(int frequency, int iFrequency)
        {
            var block = new String(BlockSelecter.GenerateBlock(frequency).Select(x => x ? 'x' : '-').ToArray());

            BlockSelecter selecter = new BlockSelecter(frequency, iFrequency, block, 3, 0, 0);
        }