Ejemplo n.º 1
0
        public void GetContactsTest()
        {
            ContactsSessionStore store = new ContactsSessionStore(httpContextAccessor: new MockHttpContextAccessor());

            List <Contact> contacts = store.GetContacts();

            Assert.NotNull(contacts);
        }
Ejemplo n.º 2
0
        public void CreateTest()
        {
            ContactsSessionStore store = new ContactsSessionStore(httpContextAccessor: new MockHttpContextAccessor());

            bool success = store.Create(contact: new Contact()
            {
                FirstName = "a",
                LastName  = "b",
                Email     = "*****@*****.**"
            });

            Assert.True(condition: success);
            Assert.Single(store.GetContacts());
        }
Ejemplo n.º 3
0
        public void FindByIdTest()
        {
            ContactsSessionStore store = new ContactsSessionStore(httpContextAccessor: new MockHttpContextAccessor());
            Contact c = new Contact()
            {
                FirstName = "a",
                LastName  = "b",
                Email     = "*****@*****.**"
            };

            store.Create(contact: c);

            Contact found = store.FindById(id: c.Id);

            Assert.Equal(expected: c.Id, actual: found.Id);
        }
Ejemplo n.º 4
0
        public void DeleteTest()
        {
            ContactsSessionStore store = new ContactsSessionStore(httpContextAccessor: new MockHttpContextAccessor());
            Contact c = new Contact()
            {
                FirstName = "a",
                LastName  = "b",
                Email     = "*****@*****.**"
            };

            store.Create(contact: c);

            bool success = store.Delete(contact: c);

            Assert.True(condition: success);
            Assert.Empty(collection: store.GetContacts());
        }
Ejemplo n.º 5
0
        public void UpdateTest()
        {
            ContactsSessionStore store = new ContactsSessionStore(httpContextAccessor: new MockHttpContextAccessor());
            Contact original           = new Contact()
            {
                FirstName = "a",
                LastName  = "b",
                Email     = "*****@*****.**"
            };
            Contact updated = new Contact()
            {
                Id        = original.Id,
                FirstName = "b"
            };

            store.Create(contact: original);

            bool    success = store.Update(contact: updated);
            Contact saved   = store.FindById(id: original.Id);

            Assert.True(condition: success);
            Assert.Equal(expected: updated.FirstName, actual: saved.FirstName);
        }