Пример #1
0
        public void AddComplaint_CorrectArgs_Success(int _clientId, int _orderId, string _description)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var testSessionToken = SessionRepository.StartNewSession(_clientId);

            var addComplaintCommand = new AddComplaintCommand
            {
                sessionToken = testSessionToken,
                orderId      = _orderId,
                description  = _description
            };

            var handler           = new AddComplaintCommandHandler();
            var result            = (SuccessInfoDto)handler.Handle(addComplaintCommand);
            var receivedComplaint = DatabaseQueryProcessor.GetComplaint(_orderId);

            SessionRepository.RemoveSession(testSessionToken);

            DatabaseQueryProcessor.Erase();

            Assert.AreEqual(receivedComplaint.description, _description);
            Assert.AreEqual(receivedComplaint.openDate, DateTime.Now.ToString("yyyy-MM-dd"));
            Assert.IsTrue(result.isSuccess);
        }
Пример #2
0
        public void AddComplaint_IncorrectClientId_Exception(int _clientId)
        {
            var testSessionToken = SessionRepository.StartNewSession(_clientId);

            var addComplaintCommand = new AddComplaintCommand
            {
                sessionToken = testSessionToken,
                orderId      = 0,
                description  = "I am dissatisfied"
            };

            var          handler = new AddComplaintCommandHandler();
            TestDelegate result  = () => handler.Handle(addComplaintCommand);

            SessionRepository.RemoveSession(testSessionToken);

            Assert.Throws <Exception>(result);
        }
Пример #3
0
        public void AddComplaint_DifferentClientId_Exception(int _orderId)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var testSessionToken = SessionRepository.StartNewSession(0);

            var addComplaintCommand = new AddComplaintCommand
            {
                sessionToken = testSessionToken,
                orderId      = _orderId,
                description  = "I am dissatisfied"
            };

            var          handler = new AddComplaintCommandHandler();
            TestDelegate result  = () => handler.Handle(addComplaintCommand);

            SessionRepository.RemoveSession(testSessionToken);

            Assert.Throws <Exception>(result);
        }
Пример #4
0
        public void AddComplaint_ComplaintAlreadyExist_Exception(int _clientId, int _orderId, string _description)
        {
            DatabaseQueryProcessor.Erase();
            Shared.FillTheDatabase();

            var testSessionToken = SessionRepository.StartNewSession(_clientId);

            var addComplaintCommand = new AddComplaintCommand
            {
                sessionToken = testSessionToken,
                orderId      = _orderId,
                description  = _description
            };

            var          handler = new AddComplaintCommandHandler();
            TestDelegate result  = () => handler.Handle(addComplaintCommand);

            SessionRepository.RemoveSession(testSessionToken);

            Assert.Throws <Exception>(result);
        }