Example #1
0
        public void Given_Name_Id_When_SetupAndRegisterNewDevice_then_AddSuceefullySetToSpecial()
        {
            //Arange
            var deviceManager = MockRepository.GenerateMock<IDeviceManager>();
            var machine = new Machine(deviceManager);
            var device = new Device { Id = 1, Name = "printer" };

            //Act
            machine.SetupAndRegisterNewDevice(device.Id, device.Name);

            //Assert
            deviceManager.AssertWasCalled(x => x.special = Arg<string>.Matches(Rhino.Mocks.Constraints.Text.StartsWith("Not")));
            deviceManager.AssertWasCalled(x => x.special = Arg<string>.Matches(Rhino.Mocks.Constraints.Text.Like("Special")));
            deviceManager.AssertWasCalled(x => x.special = Arg<string>.Matches(Rhino.Mocks.Constraints.Text.Contains("Special")));
        }
Example #2
0
        public void Given_Name_Id_When_SetupAndRegisterNewDevice_then_AddSameDeviceType()
        {
            //Arange
            var deviceManager = MockRepository.GenerateMock<IDeviceManager>();
            var machine = new Machine(deviceManager);
            var device = new Device { Id = 1, Name = "printer" };

            //Act
            machine.SetupAndRegisterNewDevice(device.Id,device.Name);

            //Assert
            deviceManager.AssertWasCalled(x => x.Add(Arg<Device>.Matches(y => y.Id == device.Id && y.Name == device.Name)));
            deviceManager.AssertWasCalled(x => x.Add(Arg<Device>.Is.Anything));
            deviceManager.AssertWasCalled(x => x.Add(Arg<Device>.Is.NotNull));
        }