Ejemplo n.º 1
0
        public void DeleteUser()
        {
            // Arrange
            ExternalService exService = new ExternalService();
            UserService service = new UserService(exService);

            using (var _session = DBSetup())
            {
                var userModel = new User()
                {
                    FirstName = "TestFN",
                    LastName = "TestLN",
                    Email = "*****@*****.**",
                    StreetAddress = "TestSA",
                    City = "TestCity",
                    State = "TestState",
                    Zip = "99999"
                };
                _session.Store(userModel);
                _session.SaveChanges();

                // Act
                string result = service.DeleteUser(_session, "users/1");

                // Assert
                Assert.IsNotNull(result);

                var user = _session.Load<User>(result);

                Assert.IsNull(user);
            }
        }
Ejemplo n.º 2
0
        public void DeleteUserFail()
        {
            // Arrange
            ExternalService exService = new ExternalService();
            UserService service = new UserService(exService);

            using (var _session = DBSetup())
            {
                // Act
                string result = service.DeleteUser(_session, "users/1");

                // Assert
                Assert.IsNull(result);
            }
        }
Ejemplo n.º 3
0
        public void UpdateUser()
        {
            // Arrange
            ExternalService exService = new ExternalService();
            UserService service = new UserService(exService);

            using (var _session = DBSetup())
            {
                var userModel = new User()
                {
                    FirstName = "TestFN",
                    LastName = "TestLN",
                    Email = "*****@*****.**",
                    StreetAddress = "TestSA",
                    City = "TestCity",
                    State = "TestState",
                    Zip = "99999"
                };
                _session.Store(userModel);
                _session.SaveChanges();

                var changeUserModel = new User()
                {
                    Id = userModel.Id,
                    FirstName = "TestFN",
                    LastName = "TestLN",
                    Email = "*****@*****.**",
                    StreetAddress = "NEWTestSA",
                    City = "TestCity",
                    State = "TestState",
                    Zip = "99999"
                };

                // Act
                User result = service.UpdateUser(_session, changeUserModel);

                // Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(result.Id, "users/1");
                Assert.AreEqual(result.StreetAddress, "NEWTestSA");
            }
        }
Ejemplo n.º 4
0
        public void UpdateUserFail()
        {
            // Arrange
            ExternalService exService = new ExternalService();
            UserService service = new UserService(exService);

            using (var _session = DBSetup())
            {
                var changeUserModel = new User()
                {
                    Id = "users/1",
                    FirstName = "TestFN",
                    LastName = "TestLN",
                    Email = "*****@*****.**",
                    StreetAddress = "NEWTestSA",
                    City = "TestCity",
                    State = "TestState",
                    Zip = "99999"
                };

                // Act
                User result = service.UpdateUser(_session, changeUserModel);

                // Assert
                Assert.IsNull(result);
            }
        }
Ejemplo n.º 5
0
        public void GetAllUsers()
        {
            // Arrange
            ExternalService exService = new ExternalService();
            UserService service = new UserService(exService);

            using (var _session = DBSetup())
            {
                var userModel1 = new User()
                {
                    FirstName = "TestFN1",
                    LastName = "TestLN1",
                    Email = "*****@*****.**",
                    StreetAddress = "TestSA1",
                    City = "TestCity1",
                    State = "TestState1",
                    Zip = "99998"
                };
                _session.Store(userModel1);

                var userModel2 = new User()
                {
                    FirstName = "TestFN2",
                    LastName = "TestLN2",
                    Email = "*****@*****.**",
                    StreetAddress = "TestSA2",
                    City = "TestCity2",
                    State = "TestState2",
                    Zip = "99999"
                };
                _session.Store(userModel2);
                _session.SaveChanges();

                // Act
                List<User> result = service.GetAllUsers(_session);

                // Assert
                Assert.IsNotNull(result);
                Assert.AreEqual(result.Count, 2);
            }
        }