Beispiel #1
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));
        }