Esempio n. 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);
            });
        }
Esempio n. 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();
            });
        }
Esempio n. 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();
            });
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }