Ejemplo n.º 1
0
        public async Task QueryOneMachinesNotFound()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new Machine
            {
                MachineId           = 1,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };
            var machineEntity2 = new Machine
            {
                MachineId           = 2,
                Name                = "Mini",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };

            rep.Get(1).Returns(machineEntity1);
            rep.Get(2).Returns(machineEntity2);

            var machine = await ctrl.Get(3);

            machine.Should().BeNull();
        }
Ejemplo n.º 2
0
        public async Task UpdateMachine()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new Machine
            {
                MachineId           = 11,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };

            rep.Get(11).Returns(machineEntity1);
            rep.GetTracking(Arg.Any <IEnumerable <int> >()).Returns(new[] { machineEntity1 });

            var machine = await ctrl.Get(11);

            machine.Name = "SuperMaxi";

            await ctrl.Update(machine);

            //await rep.Received().Update(11, Arg.Is<Machine>(x => x.Name == "SuperMaxi"));
        }
Ejemplo n.º 3
0
        public async Task DeleteMachine()
        {
            var unitOfWork = Substitute.For <IUnitOfWork>();
            var rep        = Substitute.For <IMachineRepository>();
            var repC       = Substitute.For <IConfigurationRepository>();

            var ctrl = new MachineManager(unitOfWork, rep, repC, new CNCLibUserContext(), Mapper);

            var machineEntity1 = new Machine
            {
                MachineId           = 11,
                Name                = "Maxi",
                MachineCommands     = new List <MachineCommand>(),
                MachineInitCommands = new MachineInitCommand[0]
            };

            rep.Get(1).Returns(machineEntity1);

            var machine = await ctrl.Get(1);

            machine.Name = "SuperMaxi";

            await ctrl.Delete(machine);

            rep.Received().DeleteRange(Arg.Is <IEnumerable <Machine> >(x => x.First().Name == "SuperMaxi"));
            rep.Received().DeleteRange(Arg.Is <IEnumerable <Machine> >(x => x.First().MachineId == 11));
        }