コード例 #1
0
        public async Task ClientLoginSucess()
        {
            var user = new Client()
            {
                Id       = 0,
                Name     = "user-test",
                Birthay  = new DateTime(2020, 05, 01),
                Cpf      = "test-registration",
                Password = "******"
            };
            await _repository.Add(user);

            Exception exception   = null;
            ClientJWT clientJWT   = null;
            var       clientLogin = new ClientLogin()
            {
                Password = user.Password,
                Cpf      = user.Cpf
            };

            try
            {
                clientJWT = await this._service.Login(clientLogin, new FakeAuthentication());
            }
            catch (UserNotDefinid ex)
            {
                exception = ex;
            }

            Assert.AreEqual(exception, null);
            Assert.AreEqual(clientJWT.Token, "token-implementation-fake");
        }
        public async Task SaveAppointmentSuccess()
        {
            var car = new Car()
            {
                Id = 12,
            };
            var client = new Client()
            {
                Id = 12,
            };
            var op = new Operator()
            {
                Id = 12,
            };
            await _repositoryCar.Add(car);

            await _repositoryClient.Add(client);

            await _repositoryOperator.Add(op);

            var appointment = new Appointment()
            {
                Id = 15,
                DateTimeExpectedCollected = DateTime.Now,
                DateTimeExpectedDelivery  = DateTime.Now.AddDays(10),
                HourPrice    = 10,
                HourLocation = 10,
                Subtotal     = 100,
                Amount       = 100,
                IdCar        = 12,
                IdClient     = 12,
                IdOperator   = 12
            };
            Exception exception = null;

            try
            {
                await _service.Execute(appointment);
            }catch (Exception ex)
            {
                exception = ex;
            }

            Assert.AreEqual(exception, null);
        }