예제 #1
0
        public void UpdateService_Creation_ShouldThrowException_IfPinpadInformationIsNull()
        {
            // Assert
            Assert.Throws <ArgumentNullException>(() =>
            {
                // Arrange
                IPinpadInfos infos        = null;
                IPinpadCommunication comm = new Stubs.PinpadCommunicationStub();

                // Act
                PinpadUpdateService pinpadUpdateService = new PinpadUpdateService(infos, comm);
            });
        }
예제 #2
0
        public void UpdateService_Update_ShouldThrowException_IfTheLoadMethodWasCalledButUnsucessful()
        {
            // Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                // Arrange
                IPinpadInfos infos        = new Stubs.PinpadInfosStub();
                IPinpadCommunication comm = new Stubs.PinpadCommunicationStub();
                PinpadUpdateService pinpadUpdateService = new PinpadUpdateService(infos, comm);
                string nonExistingApplicationPath       = Path.Combine(Directory.GetCurrentDirectory(), "NotExistingApp.1.2.3.zip");

                // Act and assert
                pinpadUpdateService.Load(nonExistingApplicationPath);
                pinpadUpdateService.Update();
            });
        }
예제 #3
0
        public void UpdateService_Update_ShouldThrowException_IfLoadMethodWasNotPreviouslyCalled()
        {
            // Assert
            Assert.Throws <InvalidOperationException>(() =>
            {
                // Arrange
                IPinpadInfos infos        = new Stubs.PinpadInfosStub();
                IPinpadCommunication comm = new Stubs.PinpadCommunicationStub();
                PinpadUpdateService pinpadUpdateService = new PinpadUpdateService(
                    infos,
                    comm);

                // Act
                pinpadUpdateService.Update();
            });
        }
예제 #4
0
        public void UpdateService_Load_ShouldReturnFalse_IfZippedApplicationFileDoesNotExist()
        {
            // Arrange
            IPinpadInfos         infos = new Stubs.PinpadInfosStub();
            IPinpadCommunication comm  = new Stubs.PinpadCommunicationStub();
            PinpadUpdateService  pinpadUpdateService = new PinpadUpdateService(
                infos,
                comm);
            string nonExistingApplicationPath = Path.Combine(
                Directory.GetCurrentDirectory(),
                "NotExistingApp.1.2.3.zip");

            // Act
            bool result = pinpadUpdateService.Load(nonExistingApplicationPath);

            // Assert
            Assert.IsFalse(result);
        }
예제 #5
0
        public void UpdateService_Load_ShouldReturnTrue_IfTheZippedApplicationFileExists()
        {
            // Arrange
            IPinpadInfos         infos = new Stubs.PinpadInfosStub();
            IPinpadCommunication comm  = new Stubs.PinpadCommunicationStub();
            PinpadUpdateService  pinpadUpdateService = new PinpadUpdateService(
                infos,
                comm);
            string applicationPath = Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory,
                UpdateServiceTest.MockedApplicationName);

            // Act
            bool result = pinpadUpdateService.Load(applicationPath);

            // Assert
            Assert.IsTrue(result);
        }
예제 #6
0
        public void UpdateService_Update_ShouldReturnFalse_IfThePinpadIsNotFromStone()
        {
            // Arrange
            IPinpadInfos         infos = new Stubs.PinpadInfosStub(false);
            IPinpadCommunication comm  = new Stubs.PinpadCommunicationStub();
            PinpadUpdateService  pinpadUpdateService = new PinpadUpdateService(
                infos,
                comm);
            string applicationPath = Path.Combine(
                Directory.GetCurrentDirectory(),
                UpdateServiceTest.MockedApplicationName);

            pinpadUpdateService.Load(applicationPath);

            // Act
            bool result = pinpadUpdateService.Update();

            // Assert
            Assert.IsFalse(result);
        }