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);
        }
        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)));
        }
Esempio n. 3
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));
        }
Esempio n. 4
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));
        }