示例#1
0
        public void Successful()
        {
            var persistor = new Core.Data.Persistor.Client();
            var userId    = Guid.Parse("{5CEAD906-4825-4357-A60D-F0363B247CA6}");

            var sql = Utils.User.GetInsertScript(userId, "user 1", "*****@*****.**");

            persistor.DbContext.Database.ExecuteSqlCommand(sql);

            var clientId = Guid.Empty;
            var client   = new Core.Data.Model.Client
            {
                Id          = clientId,
                Active      = true,
                CompanyName = "Client name",
                CreatedDate = DateTime.Now,
                User_Id     = userId,
            };

            persistor.Save(client);
            persistor.Commit();

            const string sqlFormatter = "IF NOT EXISTS (" +
                                        "SELECT COUNT(*) FROM Clients WHERE Id = '{0}' AND CompanyName = '{1}' AND User_Id = '{2}' " +
                                        "HAVING COUNT(*) = 1" +
                                        ") RAISERROR ('Error creating client.',16,1);";

            Assert.NotEqual(clientId, client.Id);

            sql = string.Format(sqlFormatter, client.Id, "Client name", userId);
            persistor.DbContext.Database.ExecuteSqlCommand(sql);
        }
示例#2
0
        private void VerifyDelete()
        {
            var repo = new Core.Data.Persistor.Client();
            var sql  = string.Format("IF NOT EXISTS (" +
                                     "SELECT COUNT(*) FROM Clients WHERE Id = '{0}' HAVING COUNT(*) > 0" +
                                     ") RAISERROR ('Client not found.',16,1);", _clientId);

            repo.DbContext.Database.ExecuteSqlCommand(sql);

            repo.Delete(_clientId);
            repo.Commit();

            sql = string.Format("IF EXISTS (" +
                                "SELECT COUNT(*) FROM Clients WHERE Id = '{0}' HAVING COUNT(*) > 0" +
                                ") RAISERROR ('Error deleting client.',16,1);", _clientId);

            repo.DbContext.Database.ExecuteSqlCommand(sql);
        }