예제 #1
0
        public void AddAddress_DuplicateAddress_Success(int _clientId, string _country, string _city, string _street, int _ZIPCode, int _buildingNumber, string _apartmentNumber)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var testSessionToken = SessionRepository.StartNewSession(_clientId);
            var addressExists    = DatabaseQueryProcessor.GetAddress(_clientId, _country, _city, _street, _ZIPCode, _buildingNumber, _apartmentNumber);

            if (addressExists != null)
            {
                DatabaseQueryProcessor.UpdateAddress(addressExists.addressId, false);
            }

            var addAddressCommand = new AddAddressCommand
            {
                sessionToken    = testSessionToken,
                country         = _country,
                city            = _city,
                street          = _street,
                ZIPCode         = _ZIPCode,
                buildingNumber  = _buildingNumber,
                apartmentNumber = _apartmentNumber
            };

            var handler     = new AddAddressCommandHandler();
            var addressBook = (AddressBookDto)handler.Handle(addAddressCommand);

            var record = DatabaseQueryProcessor.GetAddress(_clientId, _country, _city, _street, _ZIPCode, _buildingNumber, _apartmentNumber);

            DatabaseQueryProcessor.Erase();
            SessionRepository.RemoveSession(testSessionToken);

            Assert.IsTrue(record.isActive);
        }
예제 #2
0
        public void AddAddress_ClientDoesntExist_Exception(int _clientId)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var testSessionToken = SessionRepository.StartNewSession(_clientId);

            var addAddressCommand = new AddAddressCommand
            {
                sessionToken    = testSessionToken,
                country         = "Poland",
                city            = "Cracow",
                street          = "Urzednicza",
                ZIPCode         = 34040,
                buildingNumber  = 100,
                apartmentNumber = ""
            };

            var          handler = new AddAddressCommandHandler();
            TestDelegate result  = () => handler.Handle(addAddressCommand);

            DatabaseQueryProcessor.Erase();
            SessionRepository.RemoveSession(testSessionToken);

            Assert.Throws <Exception>(result);
        }
예제 #3
0
        public void AddAddress_AddNewAddress_Success(int _clientId, string _country, string _city, string _street, int _ZIPCode, int _buildingNumber, string _apartmentNumber)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var testSessionToken = SessionRepository.StartNewSession(_clientId);

            var addAddressCommand = new AddAddressCommand
            {
                sessionToken    = testSessionToken,
                country         = _country,
                city            = _city,
                street          = _street,
                ZIPCode         = _ZIPCode,
                buildingNumber  = _buildingNumber,
                apartmentNumber = _apartmentNumber
            };

            var handler     = new AddAddressCommandHandler();
            var addressBook = (AddressBookDto)handler.Handle(addAddressCommand);

            var record = DatabaseQueryProcessor.GetAddress(_clientId, _country, _city, _street, _ZIPCode, _buildingNumber, _apartmentNumber);

            DatabaseQueryProcessor.Erase();
            SessionRepository.RemoveSession(testSessionToken);

            Assert.IsNotNull(record);
            Assert.AreEqual(_clientId, record.clientId);
            Assert.AreEqual(_country, record.country);
            Assert.AreEqual(_city, record.city);
            Assert.AreEqual(_street, record.street);
            Assert.AreEqual(_ZIPCode, record.ZIPCode);
            Assert.AreEqual(_buildingNumber, record.buildingNumber);
            Assert.AreEqual(_apartmentNumber, record.apartmentNumber);
        }
예제 #4
0
        public void AddAddress_InvalidCountry_Exception(string _country)
        {
            var testSessionToken = SessionRepository.StartNewSession(0);

            var addAddressCommand = new AddAddressCommand
            {
                sessionToken    = testSessionToken,
                country         = _country,
                city            = "Wroclove",
                street          = "Mickiewicza",
                ZIPCode         = 30000,
                buildingNumber  = 12,
                apartmentNumber = ""
            };

            var          handler = new AddAddressCommandHandler();
            TestDelegate result  = () => handler.Handle(addAddressCommand);

            SessionRepository.RemoveSession(testSessionToken);

            Assert.Throws <Exception>(result);
        }