Example #1
0
        public MeterLogicTests()
        {
            const int roll1Length = 100;
            const int roll2Length = 200;
            const int roll3Length = 300;
            const int roll4Length = 400;
            const int roll5Length = 400;
            const int roll6Length = 400;
            const int roll7Length = 400;

            this.srcData        = new MockMeterSrc <MahloModel>();
            this.sewinQueue     = Substitute.For <ISewinQueue>();
            this.dbMfg          = Substitute.For <IDbMfg>();
            this.dbLocal        = Substitute.For <IDbLocal>();
            this.appInfo        = Substitute.For <IServiceSettings>();
            this.userAttentions = Substitute.For <IUserAttentions <MahloModel> >();
            this.criticalStops  = Substitute.For <ICriticalStops <MahloModel> >();

            this.appInfo.MinRollLengthForStyleAndRollCounting = 1;
            this.appInfo.MinRollLengthForLengthChecking       = 1;

            var stateProvider = Substitute.For <IProgramStateProvider>();

            stateProvider.GetProgramState().Returns("{}");
            this.programState = new ProgramState(stateProvider);

            var roll1 = new MahloService.Models.GreigeRoll()
            {
                Id         = 1,
                RollNo     = "12345",
                RollLength = roll1Length,
            };

            var roll2 = new MahloService.Models.GreigeRoll()
            {
                Id         = 2,
                RollNo     = "12346",
                RollLength = roll2Length,
            };

            var roll3 = new MahloService.Models.GreigeRoll()
            {
                Id         = 3,
                RollNo     = "12347",
                RollLength = roll3Length,
            };

            var roll4 = new MahloService.Models.GreigeRoll()
            {
                Id         = 4,
                RollNo     = "12348",
                RollLength = roll4Length,
            };

            var roll5 = new MahloService.Models.GreigeRoll()
            {
                Id         = 5,
                RollNo     = "12349",
                RollLength = roll5Length,
            };

            var roll6 = new MahloService.Models.GreigeRoll()
            {
                Id         = 6,
                RollNo     = "12350",
                RollLength = roll6Length,
            };

            var roll7 = new MahloService.Models.GreigeRoll()
            {
                Id         = 7,
                RollNo     = "12351",
                RollLength = roll7Length,
            };

            this.greigeRolls = new List <GreigeRoll> {
                roll1, roll2, roll3, roll4, roll5, roll6, roll7
            };

            this.sewinQueue.Rolls.Returns(new BindingList <GreigeRoll>(this.greigeRolls));

            this.target = new MahloLogic(this.dbLocal, this.srcData, this.sewinQueue, this.appInfo, this.userAttentions, this.criticalStops, this.programState, this.testSchedulers)
            {
                CurrentRoll = this.sewinQueue.Rolls[0]
            };

            this.sewinQueue.QueueChanged += Raise.Event <Action>();
            Assert.True(this.userAttentions.VerifyRollSequence);
            Assert.NotNull(this.target.CurrentRoll);
            this.userAttentions.ClearAll();
            this.target.Start();
        }