Example #1
0
        public void DeveAdicionarMesmoJogoComEmprestimoFinalizado()
        {
            var amigo      = new Friend("amigo1", "*****@*****.**", "3333", new User("mychell", "*****@*****.**"));
            var jogo       = new Game("GTA", "Aventura");
            var emprestimo = new Loan(amigo, jogo);


            amigo.AddLoan(emprestimo);
            emprestimo.EndLoan();
            amigo.AddLoan(emprestimo);

            amigo.Valid.Should().BeTrue();
        }
Example #2
0
        public void DeveValidarJogoAindaEmprestado()
        {
            var amigo      = new Friend("amigo1", "*****@*****.**", "3333", new User("mychell", "*****@*****.**"));
            var jogo       = new Game("GTA", "Aventura");
            var emprestimo = new Loan(amigo, jogo);


            amigo.AddLoan(emprestimo);
            amigo.AddLoan(emprestimo);

            amigo.Valid.Should().BeFalse();
            amigo.Notifications.Any(x => x.Message.Contains("existem empréstimos ativos para este jogo"));
        }
Example #3
0
        public void DeveRevogarTodosOsJogosEmprestadoParaoAmigo()
        {
            var amigo = new Friend("amigo1", "*****@*****.**", "3333", new User("mychell", "*****@*****.**"));
            var jogo  = new Game("GTA", "Aventura");
            var jogo2 = new Game("COD", "Aventura");


            amigo.AddLoan(new Loan(amigo, jogo));
            amigo.AddLoan(new Loan(amigo, jogo2));

            amigo.RevokeAllLoan();

            amigo.Loans.All(x => x.EndDate.HasValue).Should().BeTrue();

            amigo.Valid.Should().BeTrue();
        }
Example #4
0
        public void DeveAdicionarEmprestimo()
        {
            var amigo = new Friend("amigo1", "*****@*****.**", "3333", new User("mychell", "*****@*****.**"));
            var jogo  = new Game("GTA", "Aventura");

            amigo.AddLoan(new Loan(amigo, jogo));

            amigo.Loans.Count.Should().Be(1);
            amigo.Valid.Should().BeTrue();
        }
Example #5
0
        public void NaoDeveFinalizarEmprestimoJaFinalizado()
        {
            var amigo      = new Friend("amigo1", "*****@*****.**", "3333", new User("mychell", "*****@*****.**"));
            var jogo       = new Game("GTA", "Aventura");
            var jogo2      = new Game("COD", "Aventura");
            var emprestimo = new Loan(amigo, jogo);

            amigo.AddLoan(emprestimo);
            amigo.FinalizeLoan(emprestimo.Id);
            emprestimo.EndLoan();
            amigo.FinalizeLoan(emprestimo.Id);

            amigo.Valid.Should().BeFalse();

            amigo.Notifications.Any(x => x.Message.Contains("Emprestimo já finalizado")).Should().BeTrue();
        }
Example #6
0
        public void DeveFinalizarEmprestioAtivo()
        {
            var amigo      = new Friend("amigo1", "*****@*****.**", "3333", new User("mychell", "*****@*****.**"));
            var jogo       = new Game("GTA", "Aventura");
            var jogo2      = new Game("COD", "Aventura");
            var emprestimo = new Loan(amigo, jogo);


            amigo.AddLoan(emprestimo);

            amigo.FinalizeLoan(emprestimo.Id);

            amigo.Loans.All(x => x.EndDate.HasValue).Should().BeTrue();

            amigo.Valid.Should().BeTrue();
        }
Example #7
0
        public void Test_AddLoan(bool isLoanNull)
        {
            var game    = new Game("FIFA2020", "Sport", _user);
            var address = new Address("12", "Av. Paulista", "Bela Vista", "São Paulo");
            var friend  = new Friend("Marcos", "*****@*****.**", "01598988587", address, _user);
            var loan    = isLoanNull ? null : new Loan(friend, game);

            friend.AddLoan(loan);
            if (isLoanNull)
            {
                Assert.Equal(0, friend.Loans.Count);
            }
            else
            {
                Assert.Equal(1, friend.Loans.Count);
            }
        }