コード例 #1
0
        public void updateUser()
        {
            if (!testingUpdateUser)
            {
                return;
            }

            //Test reading a user
            UserDataGateway userGateway = new UserDataGateway();


            UserDataModel user;

            user = userGateway.read(16);

            if (user != null)
            {
                user.Display_name = "Schimbatul Ion";


                Console.WriteLine(user.Display_name);

                userGateway.update(user);
            }
            else
            {
                Console.WriteLine("User not found");
            }
        }
コード例 #2
0
        public void TestFindBy()
        {
            var userDataGateway    = new UserDataGateway(new UserContext(UserDbContextOptions));
            var accountDataGateway = new AccountDataGateway(new AccountContext(AccountDbContextOptions));
            var service            = new RegistrationService(userDataGateway, accountDataGateway);

            var info = service.CreateUserWithAccount("aUser");

            Assert.Equal("aUser", info.Name);
        }
コード例 #3
0
        public void TestCreate()
        {
            var gateway = new UserDataGateway(new UserContext(DbContextOptions));

            gateway.Create("aUser");

            var names = Support.QuerySql("select name from users");

            Assert.Equal("aUser", names[0]["name"]);
        }
コード例 #4
0
        public void TestFindBy()
        {
            var userDataGateway    = new UserDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var accountDataGateway = new AccountDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var service            = new RegistrationService(userDataGateway, accountDataGateway);

            var info = service.CreateUserWithAccount("aUser");

            Assert.Equal("aUser", info.Name);
        }
コード例 #5
0
        public void TestCreate()
        {
            var template = new DatabaseTemplate(_dataSourceConfig);
            var gateway  = new UserDataGateway(template);

            gateway.Create("aUser");

            var names = template.Query("select name from users", reader => reader.GetString(0),
                                       new List <DbParameter>());

            Assert.Equal("aUser", names.First());
        }
コード例 #6
0
        public void deleteUser()
        {
            if (!testingDeleteUser)
            {
                return;
            }

            //Test reading a user
            UserDataGateway userGateway = new UserDataGateway();

            userGateway.delete(16);
        }
コード例 #7
0
        public void TestFindBy()
        {
            Support.ExecSql(
                @"insert into users (id, name) values (42346, 'aName'), (42347, 'anotherName'), (42348, 'andAnotherName');");

            var gateway = new UserDataGateway(new UserContext(DbContextOptions));

            var actual = gateway.FindObjectBy(42347);

            Assert.Equal(42347, actual.Id);
            Assert.Equal("anotherName", actual.Name);

            Assert.Null(gateway.FindObjectBy(42));
        }
コード例 #8
0
        public void addUser()
        {
            if (!testingAddUser)
            {
                return;
            }

            //Test adding a user
            UserDataModel newUser = new UserDataModel("vasilescu", "1233456", "Vasilescu Patrascu", 1);

            UserDataGateway userGateway = new UserDataGateway();

            userGateway.add(newUser);
        }
コード例 #9
0
        public void TestPost()
        {
            _testScenarioSupport.LoadTestScenario("jacks-test-scenario");

            var userDataGateway    = new UserDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var accountDataGateway = new AccountDataGateway(new DatabaseTemplate(_dataSourceConfig));
            var service            = new RegistrationService(userDataGateway, accountDataGateway);

            var controller = new RegisationController(service);
            var value      = controller.Post(new UserInfo(-1, "aUser", ""));
            var actual     = (UserInfo)((ObjectResult)value).Value;

            Assert.True(actual.Id > 0);
            Assert.Equal("aUser", actual.Name);
            Assert.Equal("registration info", actual.Info);
        }
コード例 #10
0
        public void TestFindBy()
        {
            var support = new TestDatabaseSupport(_dataSourceConfig);

            support.ExecSql(
                @"insert into users (id, name) values (42346, 'aName'), (42347, 'anotherName'), (42348, 'andAnotherName');");

            var gateway = new UserDataGateway(new DatabaseTemplate(_dataSourceConfig));

            var actual = gateway.FindObjectBy(42347);

            Assert.Equal(42347, actual.Id);
            Assert.Equal("anotherName", actual.Name);

            Assert.Null(gateway.FindObjectBy(42));
        }
コード例 #11
0
        public void readUser()
        {
            if (!testingReadUser)
            {
                return;
            }

            //Test reading a user
            UserDataGateway userGateway = new UserDataGateway();

            UserDataModel user;

            user = userGateway.read(16);


            Console.WriteLine(user.Display_name);
        }