예제 #1
0
        public void LockDevice_GivenUnlockState_ExpectTrue()
        {
            //Arrange
            var guid     = Guid.NewGuid();
            var database = Substitute.For <IDatabase>();

            database.GetMachineDevice(guid).Returns(new MachineDevice(guid));
            database.GetAllMachineDeviceIds().Returns(new List <Guid> {
                guid
            });
            var scheduler = new Scheduler(database);
            var api       = new MachineApi(database, scheduler);

            //Act && Assert
            Assert.IsTrue(api.LockMachine(guid, DateTime.Now));
        }
예제 #2
0
        public void LockDevice_GivenAlreadyReservedSlot_ExpectFalse()
        {
            //Arrange
            var guid     = Guid.NewGuid();
            var database = Substitute.For <IDatabase>();

            database.GetMachineDevice(guid).Returns(new MachineDevice(guid)
            {
                IsLocked = true
            });
            database.GetAllMachineDeviceIds().Returns(new List <Guid> {
                guid
            });
            var scheduler = new Scheduler(database);
            var api       = new MachineApi(database, scheduler);

            //Act
            scheduler.Reserve(guid, DateTime.Now);

            //Act && Assert
            Assert.IsFalse(api.LockMachine(guid, DateTime.Now));
        }