public void GetAll_returns_preexisting_app()
        {
            var clientRepository = new ClientInMemoryRepository();
            var client           = new Client("Client Name", "John", "1234567890", "*****@*****.**");

            clientRepository.Store(client);

            var repository = new UserInMemoryRepository(clientRepository);
            var user1      = new User(new UserDto {
                Id = Guid.NewGuid(), ClientId = client.Identifier.Identity, Username = "******", Password = "******", FirstName = "John", LastName = "Doe", EmailAddress = "*****@*****.**"
            });
            var user2 = new User(new UserDto {
                Id = Guid.NewGuid(), ClientId = client.Identifier.Identity, Username = "******", Password = "******", FirstName = "John", LastName = "Doe", EmailAddress = "*****@*****.**"
            });
            var user3 = new User(new UserDto {
                Id = Guid.NewGuid(), ClientId = client.Identifier.Identity, Username = "******", Password = "******", FirstName = "John", LastName = "Doe", EmailAddress = "*****@*****.**"
            });

            repository.Store(user1);
            repository.Store(user2);
            repository.Store(user3);

            var list = repository.All();

            list.Any(u => u.UserId.Equals(user1.Identifier.Id)).ShouldBeTrue();
            list.Any(u => u.UserId.Equals(user2.Identifier.Id)).ShouldBeTrue();
            list.Any(u => u.UserId.Equals(user3.Identifier.Id)).ShouldBeTrue();
            list.Count.ShouldBe(3);
        }
Exemplo n.º 2
0
        public void ReturnsTrueWithUniqueClientName()
        {
            var repository    = new ClientInMemoryRepository();
            var specification = new ContactEmailUniqueSpecification(repository);

            Client client = new Client("Client", "John Doe", "1234567890", "*****@*****.**");

            Assert.IsTrue(specification.IsSatisifiedBy(client));
        }
Exemplo n.º 3
0
        public void ReturnsTrueWithUniqueClientName()
        {
            var repository    = new ClientInMemoryRepository();
            var specification = new ClientNameUniqueSpecification(repository);

            Client client = new Client(Guid.NewGuid().ToString(), "John Doe", "1234567890", "*****@*****.**");

            Assert.IsTrue(specification.IsSatisifiedBy(client));
        }
Exemplo n.º 4
0
        public void ReturnsTrueWithDuplicateExistingClient()
        {
            var repository    = new ClientInMemoryRepository();
            var specification = new ContactEmailUniqueSpecification(repository);

            Client client = new Client("Client", "John Doe", "1234567890", "*****@*****.**");

            repository.Store(client);

            Assert.IsTrue(specification.IsSatisifiedBy(client));
        }
Exemplo n.º 5
0
        public void ReturnsFalseWithDuplicateUniqueClient()
        {
            var repository    = new ClientInMemoryRepository();
            var specification = new ContactEmailUniqueSpecification(repository);

            Client client = new Client("Client 1", "John Doe", "1234567890", "*****@*****.**");

            repository.Store(client);
            Client duplicateClient = new Client("Client 2", "John Doe", "1234567890", "*****@*****.**");

            Assert.IsFalse(specification.IsSatisifiedBy(duplicateClient));
        }
        public void AllGetsAllValues()
        {
            ClientInMemoryRepository clientRepository = new ClientInMemoryRepository();

            ClientInMemoryRepository.ClearDictionary();
            var client1 = new Client(ClientName, ContactName, Phone, Email);
            var client2 = new Client(ClientName, ContactName, Phone, Email);
            var client3 = new Client(ClientName, ContactName, Phone, Email);

            clientRepository.Store(client1);
            clientRepository.Store(client2);
            clientRepository.Store(client3);
            IReadOnlyList <Client> clientList = clientRepository.All();

            Assert.That(clientList.Count, Is.EqualTo(5));
            Assert.IsTrue(clientList.Any(c => c.Identifier.Equals(client1.Identifier)));
            Assert.IsTrue(clientList.Any(c => c.Identifier.Equals(client2.Identifier)));
            Assert.IsTrue(clientList.Any(c => c.Identifier.Equals(client3.Identifier)));
        }
        public void GetAllReturnsAllClients()
        {
            ClientInMemoryRepository.ClearDictionary();
            var clientService = new ClientService();

            clientService.SaveNewClient(new ClientViewModel {
                ClientName = ClientName + Guid.NewGuid().ToString(), ContactName = ContactName, ContactPhone = Phone, ContactEmail = "0" + Email
            });
            clientService.SaveNewClient(new ClientViewModel {
                ClientName = ClientName + Guid.NewGuid().ToString(), ContactName = ContactName, ContactPhone = Phone, ContactEmail = "1" + Email
            });
            clientService.SaveNewClient(new ClientViewModel {
                ClientName = ClientName + Guid.NewGuid().ToString(), ContactName = ContactName, ContactPhone = Phone, ContactEmail = "2" + Email
            });
            clientService.SaveNewClient(new ClientViewModel {
                ClientName = ClientName + Guid.NewGuid().ToString(), ContactName = ContactName, ContactPhone = Phone, ContactEmail = "3" + Email
            });
            var clientList = clientService.GetAll();

            Assert.That(clientList.Count, Is.EqualTo(6));
        }