public void MakeSampleSelecterTest_100PCT() { var st = new StratumModel() { Method = "100PCT" }; var sg = new SampleGroupModel() { Stratum = st, SampleSelectorState = "something", SampleSelectorType = "something" }; sg.SampleSelectorState = null; Assert.IsNull(sg.MakeSampleSelecter()); Assert.IsNull(sg.Sampler); }
public void GetCountByHotKeyTest() { var stratum = new StratumModel(); var counts = new CountTreeVM[] { new CountTreeVM() { Tally = new TallyDO() { Hotkey = "A" } }, new CountTreeVM() {Tally = new TallyDO() { Hotkey = "Banana" } }, new CountTreeVM() {Tally = new TallyDO() { Hotkey = "cat" } }}; var samplegroups = new SampleGroupModel[] { new SampleGroupModel() { Counts = counts } }; stratum.SampleGroups = new List<SampleGroupModel>(samplegroups); Assert.IsTrue(stratum.GetCountByHotKey('A') == counts[0]); Assert.IsTrue(stratum.GetCountByHotKey('B') == counts[1]); Assert.IsTrue(stratum.GetCountByHotKey('C') == counts[2]); Assert.IsNull(stratum.GetCountByHotKey('0')); }
public void TestTreeTally() { var st = new StratumModel(); st.Method = CruiseDAL.Schema.CruiseMethods.STR; var sg = new SampleGroupModel(); sg.Stratum = st; sg.SamplingFrequency = 5; sg.InsuranceFrequency = 0; sg.SampleSelectorType = CruiseDAL.Enums.SampleSelectorType.Block.ToString(); CountTreeVM count = new CountTreeVM(); count.SampleGroup = sg; int numSamples = 10000; for (int i = 0; i < numSamples; i++) { _de.OnTally(count); } System.Diagnostics.Debug.WriteLine("Sample Count = " + _controller.SampleCount.ToString()); System.Diagnostics.Debug.WriteLine("ISample Count = " + _controller.ISampleCount.ToString()); }
public void PopulateHotKeyLookupTest() { var stratum = new StratumModel(); var counts = new CountTreeVM[] { new CountTreeVM() { Tally = new TallyDO() { Hotkey = "A" } }, new CountTreeVM() {Tally = new TallyDO() { Hotkey = "Banana" } }, new CountTreeVM() {Tally = new TallyDO() { Hotkey = "cat" } }}; var samplegroups = new SampleGroupModel[] { new SampleGroupModel() { Counts = counts } }; stratum.SampleGroups = new List<SampleGroupModel>(samplegroups); Assert.IsNotNull(stratum.HotKeyLookup); stratum.PopulateHotKeyLookup(); Assert.IsNotNull(stratum.HotKeyLookup); Assert.IsTrue(stratum.HotKeyLookup.ContainsKey('A')); Assert.IsTrue(stratum.HotKeyLookup.ContainsKey('B')); Assert.IsTrue(stratum.HotKeyLookup.ContainsKey('C')); }
public virtual TreeVM CreateNewTreeEntry(SampleGroupModel sg, TreeDefaultValueDO tdv, bool isMeasure) { Debug.Assert(this.CuttingUnit != null); var newTree = this.CuttingUnit.CreateNewTreeEntryInternal(this.Stratum, sg, tdv, isMeasure); newTree.Plot = this; newTree.TreeNumber = this.HighestTreeNum + 1; newTree.TreeCount = 1; return newTree; }
public SubPop(SampleGroupModel sg, TreeDefaultValueDO tdv) { this.SG = sg; this.TDV = tdv; }
internal TreeVM CreateNewTreeEntryInternal(StratumModel stratum , SampleGroupModel sg , TreeDefaultValueDO tdv , bool isMeasure) { TreeVM newTree = new TreeVM(this.DAL); newTree.TreeCount = 0; newTree.CountOrMeasure = (isMeasure) ? "M" : "C"; newTree.CuttingUnit = this; if (sg != null) { newTree.SampleGroup = sg; if (tdv == null) { if (sg.TreeDefaultValues.IsPopulated == false) { sg.TreeDefaultValues.Populate(); } if (sg.TreeDefaultValues.Count == 1) { tdv = sg.TreeDefaultValues[0]; } } } if (stratum != null) { newTree.Stratum = stratum; } if (tdv != null) { newTree.SetTreeTDV(tdv); } newTree.Validate(); //newTree.Save(); return newTree; }
public TreeVM CreateNewTreeEntry(StratumModel stratum , SampleGroupModel sg , TreeDefaultValueDO tdv , bool isMeasure) { var tree = CreateNewTreeEntryInternal(stratum, sg, tdv, isMeasure); tree.TreeNumber = GetNextNonPlotTreeNumber(); return tree; }
public void MakeSampleSelecterTest_F3P() { var st = new StratumModel() { Method = "F3P" }; var sg = new SampleGroupModel() { Stratum = st, SampleSelectorState = null, KZ = 100 }; Assert.IsNotNull(sg.MakeSampleSelecter()); Assert.IsNotNull(sg.Sampler); Assert.IsInstanceOfType(sg.Sampler, typeof(FMSC.Sampling.ThreePSelecter)); Assert.AreEqual(100, ((ThreePSelecter)sg.Sampler).KZ); }
void MakeSampleSelecterTest_FCM_PCM_helper(string method) { var st = new StratumModel() { Method = method }; //test: if sampling freq is 0 //then Sampler is null var sg = new SampleGroupModel() { Stratum = st, SamplingFrequency = 0 }; Assert.IsNull(sg.MakeSampleSelecter()); Assert.IsNull(sg.Sampler); //test: if sampling freq is > 0 //AND SampleSelectorType is not defined //THEN Sampler is not null //AND is of type Systematic sg = new SampleGroupModel() { Stratum = st, SamplingFrequency = 1, InsuranceFrequency = 1 }; Assert.IsNotNull(sg.MakeSampleSelecter()); Assert.IsNotNull(sg.Sampler); Assert.IsInstanceOfType(sg.Sampler, typeof(FMSC.Sampling.SystematicSelecter)); var sampler = sg.Sampler as FMSC.Sampling.IFrequencyBasedSelecter; Assert.AreEqual(1, sampler.Frequency); Assert.AreEqual(1, sampler.ITreeFrequency); }
public void MakeSampleSelecterTest_STR() { var st = new StratumModel() { Method = "STR" }; //test: if sampling freq is 0 //then Sampler is null var sg = new SampleGroupModel() { Stratum = st, SamplingFrequency = 0, SampleSelectorState = "something" }; Assert.IsNull(sg.MakeSampleSelecter()); Assert.IsNull(sg.Sampler); //test: if sampling freq is > 0 //AND SampleSelectorType is not defined //THEN Sampler is not null //AND is of type Blocked sg = new SampleGroupModel() { Stratum = st, SamplingFrequency = 1, SampleSelectorState = "something" }; Assert.IsNotNull(sg.MakeSampleSelecter()); Assert.IsNotNull(sg.Sampler); Assert.IsInstanceOfType(sg.Sampler, typeof(FMSC.Sampling.BlockSelecter)); var blockSampler = sg.Sampler as FMSC.Sampling.BlockSelecter; Assert.AreEqual(1, blockSampler.Frequency); //test: if sampling freq is > 0 //AND SampleSelectorType is Systematic //THEN Sampler is not null //AND is of type Systematic sg = new SampleGroupModel() { Stratum = st, SamplingFrequency = 1, SampleSelectorType = "SystematicSelecter", SampleSelectorState = "something" }; Assert.IsNotNull(sg.MakeSampleSelecter()); Assert.IsNotNull(sg.Sampler); Assert.IsInstanceOfType(sg.Sampler, typeof(FMSC.Sampling.SystematicSelecter)); var systmaticSampler = sg.Sampler as FMSC.Sampling.SystematicSelecter; Assert.AreEqual(1, systmaticSampler.Frequency); }
public override TreeVM CreateNewTreeEntry(SampleGroupModel sg, TreeDefaultValueDO tdv, bool isMeasure) { return base.CreateNewTreeEntry(sg, tdv, false); }