예제 #1
0
            protected override void Given()
            {
                entity1 = new Employee {
                    Name = "Bob", Login = "******"
                };
                entity1Type      = entity1.GetType();
                identityProperty = entity1Type.GetProperty("Id");
                identityType     = identityProperty.PropertyType;
                id = Guid.NewGuid();

                documentConvention = Fake <ICouchDocumentConvention>();
                documentConvention.GetIdentityPropertyFor(entity1Type).Returns(identityProperty);
                documentConvention.GenerateIdentityFor(identityType).Returns(id);

                bulkDocsResults    = new BulkDocsResult[1];
                bulkDocsResults[0] = new BulkDocsResult {
                    Id = id.ToString(), Rev = "123456"
                };
                couchProxy = Fake <ICouchProxy>();
                couchProxy.Execute <BulkDocsResult[]>(Arg.Any <BulkDocsCommand>()).Returns(bulkDocsResults);

                couchDatabase = Fake <ICouchDatabase>();
                couchDatabase.CouchDocumentConvention.Returns(documentConvention);
                couchDatabase.Name.Returns("ottoman-test-database");
                couchDatabase.CouchProxy.Returns(couchProxy);
            }
예제 #2
0
            protected override void Given()
            {
                documentId       = Guid.NewGuid();
                entity1Type      = typeof(Employee);
                identityProperty = entity1Type.GetProperty("Id");

                documentConvention = Fake <ICouchDocumentConvention>();
                documentConvention.GetIdentityPropertyFor(entity1Type).Returns(identityProperty);

                var couchDocument = new CouchDocument();

                couchDocument.Add("_id", documentId.ToString());
                couchDocument.Add("_rev", "123456");
                couchDocument.Add("Type", entity1Type.Name);
                couchDocument.Add("Name", "Bob");
                couchDocument.Add("Login", "boblogin");

                bulkDocsResults    = new BulkDocsResult[1];
                bulkDocsResults[0] = new BulkDocsResult {
                    Id = documentId.ToString(), Rev = "123456"
                };
                couchProxy = Fake <ICouchProxy>();
                couchProxy.Execute <CouchDocument>(Arg.Any <GetDocumentCommand>()).Returns(couchDocument);
                couchProxy.Execute <BulkDocsResult[]>(Arg.Any <BulkDocsCommand>()).Returns(bulkDocsResults);

                couchDatabase = Fake <ICouchDatabase>();
                couchDatabase.Name.Returns("ottoman-test-database");
                couchDatabase.CouchProxy.Returns(couchProxy);
                couchDatabase.CouchDocumentConvention.Returns(documentConvention);
            }
예제 #3
0
        public Find_Discriminator()
        {
            var client = new CouchClient("http://localhost");

            _rebels       = client.GetDatabase <Rebel>(_databaseName, nameof(Rebel));
            _simpleRebels = client.GetDatabase <SimpleRebel>(_databaseName, nameof(SimpleRebel));

            var mainRebel = new Rebel
            {
                Id     = Guid.NewGuid().ToString(),
                Name   = "Luke",
                Age    = 19,
                Skills = new List <string> {
                    "Force"
                }
            };
            var rebelsList = new List <Rebel>
            {
                mainRebel
            };

            _response = new
            {
                Docs = rebelsList
            };
        }
예제 #4
0
 public CouchDocumentSession(ICouchDatabase couchDatabase)
 {
     CouchDatabase     = couchDatabase;
     IdentityMap       = new Dictionary <string, object>();
     EntityMetadataMap = new Dictionary <object, EntityMetadata>();
     DeletedEntities   = new HashSet <object>();
 }
예제 #5
0
        public Find_Discriminator()
        {
            var client = new CouchClient("http://localhost");

            _rebels       = client.GetDatabase <Rebel>(_databaseName, nameof(Rebel));
            _simpleRebels = client.GetDatabase <SimpleRebel>(_databaseName, nameof(SimpleRebel));
        }
예제 #6
0
 public void SetUp()
 {
     var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
     var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
     server = new CouchServer(host, port);
     db = server.GetNewDatabase(DbName);
 }
예제 #7
0
 internal static Task <CouchViewList <TKey, TValue, TDoc> > GetDetailedViewAsync <TKey, TValue, TDoc>(
     this ICouchDatabase <TDoc> db,
     OpenIddictView <TKey, TValue, TDoc> view,
     CouchViewOptions <TKey>?options     = null,
     CancellationToken cancellationToken = default)
     where TDoc : CouchDocument
 {
     return(db.GetDetailedViewAsync <TKey, TValue>(view.Design, view.Value, options, cancellationToken));
 }
예제 #8
0
        public static void InsertItemToCloudant(FeedItemSP item)
        {
            CouchServer    server   = new CouchServer("xamfia.cloudant.com", 5984, "xamfia", "123400");
            ICouchDatabase database = server.GetDatabase("docs");

            //var docs = database.GetAllDocuments();
            //string doc = "{'title':'test','tags':'mn,jv'}";
            database.WriteDocument(ItemToJson(item), item.FeedItemId.ToString());
        }
예제 #9
0
        private async Task InitDatabasesAsync <TSource>(PropertyInfo propertyInfo, CouchOptions options)
            where TSource : CouchDocument
        {
            ICouchDatabase <TSource> database = options.CheckDatabaseExists
                ? await Client.GetOrCreateDatabaseAsync <TSource>().ConfigureAwait(false)
                : Client.GetDatabase <TSource>();

            propertyInfo.SetValue(this, database);
        }
예제 #10
0
        /// <summary>
        /// Change the password of the given user.
        /// </summary>
        /// <typeparam name="TCouchUser">The type of user.</typeparam>
        /// <param name="database">The users database.</param>
        /// <param name="user">The user to update.</param>
        /// <param name="password">The password.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken" /> to observe while waiting for the task to complete.</param>
        /// <returns>A task that represents the asynchronous operation. The task result contains the updated user.</returns>
        public static Task <TCouchUser> ChangeUserPassword <TCouchUser>(this ICouchDatabase <TCouchUser> database, TCouchUser user,
                                                                        string password, CancellationToken cancellationToken = default)
            where TCouchUser : CouchUser
        {
            Check.NotNull(database, nameof(database));
            Check.NotNull(user, nameof(user));
            Check.NotNull(password, nameof(password));

            user.Password = password;
            return(database.AddOrUpdateAsync(user, false, cancellationToken));
        }
예제 #11
0
파일: Star.cs 프로젝트: Lemon30/spacegame
    /// <summary>
    /// Initializes spawner object using information 
    /// gathered from database.
    /// </summary>
    /// <param name="starID">Document ID of the star.</param>
    public void GetStar(ICouchDatabase dbObject, string starID)
    {
        starInfo = dbObject.GetDocument<StarInfo>(starID);

        // Planets inside the solar system.
        foreach (var planet in starInfo.planets) {
            Planet uPlanet = gameObject.AddComponent<Planet>();
            uPlanet.planetInfo = planet;
            planets.Add(uPlanet);
        }
    }
예제 #12
0
파일: CouchTest.cs 프로젝트: grueni/Divan
 public void SetUp()
 {
     var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
       var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
       var username = ConfigurationManager.AppSettings["Username"] ?? String.Empty;
       var password = ConfigurationManager.AppSettings["Password"] ?? String.Empty;
       if (username.Equals(String.Empty))
         server = new CouchServer(host, port);
       else
           server = new CouchServer(host, port,username,password);
        DbName = GetNewDbName();
        db = server.GetNewDatabase(DbName);
 }
예제 #13
0
            protected override void Given()
            {
                id      = Guid.NewGuid();
                entity1 = new Employee {
                    Id = id, Name = "Bob", Login = "******"
                };
                entity1Type      = entity1.GetType();
                identityProperty = entity1Type.GetProperty("Id");

                documentConvention = Fake <ICouchDocumentConvention>();
                documentConvention.GetIdentityPropertyFor(entity1Type).Returns(identityProperty);

                couchDatabase = Fake <ICouchDatabase>();
                couchDatabase.CouchDocumentConvention.Returns(documentConvention);
            }
예제 #14
0
        public void SetUp()
        {
            var host = ConfigurationManager.AppSettings["CouchHost"] ?? "localhost";
            var port = Convert.ToInt32(ConfigurationManager.AppSettings["CouchPort"] ?? "5984");
            server = new CouchServer(host, port);
            DbName = GetNewDbName();
            db = server.GetNewDatabase(DbName);
            Car car = null;

            for (int i = 0; i < 10; i++)
            {
                car = new Car("Saab", "93", 170 + i);
                db.SaveDocument(car);
            }
            tempView = db.NewTempView("test", "test", "if (doc.docType && doc.docType == 'car') emit(doc.Hps, doc);");
        }
예제 #15
0
 static void GetWordTranslation(string word, ICouchDatabase database)
 {
     try
     {
         JObject ourWord = JObject.Parse(database.GetDocument(word).ToString());
         Console.ForegroundColor = ConsoleColor.Yellow;
         Console.WriteLine("{0} - {1}", word, (string)ourWord["translation"]);
         Console.ResetColor();
     }
     catch (Exception)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("This word don't exist in the dictionary");
         Console.ResetColor();
     }
 }
예제 #16
0
        static void CreateWord(string word, string translation, ICouchDatabase database)
        {
            if (database.GetDocument(word) == null)
            {
                database.CreateDocument("{\"_id\": \"" + word + "\", \"word\": \"" + word + "\", \"translation\": \"" + translation + "\"}");

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Word added");
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The word already exist");
                Console.ResetColor();
            }
        }
예제 #17
0
        static void CreateWord(string word, string translation, ICouchDatabase database)
        {
            if (database.GetDocument(word) == null)
            {
                database.CreateDocument("{\"_id\": \"" + word + "\", \"word\": \"" + word + "\", \"translation\": \"" + translation + "\"}");

                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("Word added");
                Console.ResetColor();
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("The word already exist");
                Console.ResetColor();
            }
        }
예제 #18
0
        static void GetWordTranslation(string word, ICouchDatabase database)
        {
            try
            {
                JObject ourWord = JObject.Parse(database.GetDocument(word).ToString());
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("{0} - {1}", word, (string)ourWord["translation"]);
                Console.ResetColor();

            }
            catch (Exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("This word don't exist in the dictionary");
                Console.ResetColor();
            }
        }
예제 #19
0
 static void ListAllLords(ICouchDatabase database)
 {
     try
     {
         var allWords = database.GetAllDocuments();
         foreach (var item in allWords)
         {
             Console.ForegroundColor = ConsoleColor.Yellow;
             Console.WriteLine(item.Obj["word"] + " - " + item.Obj["translation"]);
             Console.ResetColor();
         }
     }
     catch (Exception)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("The dictionary is empty");
         Console.ResetColor();
     }
 }
예제 #20
0
 static void ListAllLords(ICouchDatabase database)
 {
     try
     {
         var allWords = database.GetAllDocuments();
         foreach (var item in allWords)
         {
             Console.ForegroundColor = ConsoleColor.Yellow;
             Console.WriteLine(item.Obj["word"] + " - " + item.Obj["translation"]);
             Console.ResetColor();
         }
     }
     catch (Exception)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("The dictionary is empty");
         Console.ResetColor();
     }
 }
예제 #21
0
        /// <summary>
        /// Processes the expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="db">The db.</param>
        /// <param name="definition">The view definition.</param>
        /// <returns></returns>
        public ExpressionVisitor ProcessExpression(Expression expression, ICouchDatabase db, ICouchViewDefinition definition)
        {
            Query = db.Query(definition);
            VisitExpression(expression);

            switch (keys.Count)
            {
                case 0: // 0 keys means it's a range query. do nothing.
                    break;
                case 1: // 1 key means it's a single Equals or a Contains on a single.
                    Query.Key(keys[0]);
                    break;
                default: // neither 0 nor 1 means that we've got a set of keys to test.
                    Query.Keys(keys);
                    break;
            }

            return this;
        }
예제 #22
0
	// Use this for initialization
	void Awake () {
		// Singleton
		if (gameMaster == null) {
			DontDestroyOnLoad (gameObject);
			gameMaster = this;
		} else if (gameMaster != this)
			Destroy (gameObject);
		
		// Establish connection with the database
		var server = new CouchServer (db_host, db_port);
		database = server.GetDatabase (db);
			
		// Fetch the home planet details from the database
		// and create a global planet object called myPlanet

		// If some attribute which belongs to a star will be called, 
		// then it is necessary that a Star object to be created.
		// starID should be recognized from beginning and it should be 
		// known that which planet we are on.
		string starID = "star-1"; // Subject to change -> string to int
        Star currentStar = gameObject.AddComponent<Star>();
		selectedStar = currentStar;
        currentStar.GetStar(database, starID);

        // Fetch all stars for the galaxy generation
        currentStar.GetAllStars(database);
        stars = currentStar.starDBIter;

        // Get planet from current selected star.
        Planet currentPlanet = currentStar.planets[2];
		myPlanet = currentPlanet;

        myPlanet.initTiles();
        myTiles = currentPlanet.tiles;
		// Where iz ma tiles?

		foreach (Tile tile in myTiles) {
			
		}

		// Start Resource Generation
		InvokeRepeating("UpdateResources", 0, 1);
	}
예제 #23
0
        /// <summary>
        /// Processes the expression.
        /// </summary>
        /// <param name="expression">The expression.</param>
        /// <param name="db">The db.</param>
        /// <param name="definition">The view definition.</param>
        /// <returns></returns>
        public ExpressionVisitor ProcessExpression(Expression expression, ICouchDatabase db, ICouchViewDefinition definition)
        {
            Query = db.Query(definition);
            VisitExpression(expression);

            switch (keys.Count)
            {
            case 0:     // 0 keys means it's a range query. do nothing.
                break;

            case 1:     // 1 key means it's a single Equals or a Contains on a single.
                Query.Key(keys[0]);
                break;

            default:     // neither 0 nor 1 means that we've got a set of keys to test.
                Query.Keys(keys);
                break;
            }

            return(this);
        }
예제 #24
0
        public SupportByCombination_Tests()
        {
            var client = new CouchClient("http://localhost");

            _rebels    = client.GetDatabase <Rebel>();
            _mainRebel = new Rebel
            {
                Id     = Guid.NewGuid().ToString(),
                Name   = "Luke",
                Age    = 19,
                Skills = new List <string> {
                    "Force"
                }
            };
            _rebelsList = new List <Rebel>
            {
                _mainRebel
            };
            _response = new
            {
                Docs = _rebelsList
            };
        }
예제 #25
0
 public Database_Tests()
 {
     _client = new CouchClient("http://localhost");
     _rebels = _client.GetDatabase <Rebel>();
 }
예제 #26
0
 public override IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
 {
     return db.GetDocument<Car>(Id);
 }
예제 #27
0
        static void Main()
        {
            //This is real username and password and must work with them
            CouchServer    server    = new CouchServer("testuser.cloudant.com", 5984, "testuser", "testpassword");
            ICouchDatabase database  = server.GetDatabase("dictionary");
            bool           isWorking = true;

            ICouchDocument doc = database.GetDocument("game");


            while (isWorking)
            {
                Console.WriteLine("For add new word press : 1");
                Console.WriteLine("For finding a translation for given word press 2");
                Console.WriteLine("For list all words and their translations press 3");
                Console.WriteLine("For exit press 4");

                string command = Console.ReadLine();
                switch (command)
                {
                case "1":
                {
                    Console.WriteLine("Enter word");
                    string word = Console.ReadLine();
                    Console.WriteLine("Enter translation");
                    string translation = Console.ReadLine();

                    CreateWord(word, translation, database);
                }
                break;

                case "2":
                {
                    Console.WriteLine("Enter word");
                    string word = Console.ReadLine();

                    GetWordTranslation(word, database);
                }
                break;

                case "3":
                {
                    ListAllLords(database);
                }
                break;

                case "4":
                {
                    isWorking = false;
                }
                break;

                default:
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Unknown Command");
                    Console.ResetColor();
                }
                break;
                }
            }
        }
 public override IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
 {
     return(db.GetDocument <Car>(Id));
 }
예제 #29
0
 /// <summary>
 /// Processes the expression.
 /// </summary>
 /// <param name="expression">The expression.</param>
 /// <param name="db">The db.</param>
 /// <param name="design">The name of the design document.</param>
 /// <param name="view">The name of the view.</param>
 /// <returns></returns>
 public ExpressionVisitor ProcessExpression(Expression expression, ICouchDatabase db, string design, string view)
 {
     Query = db.Query(design, view);
     VisitExpression(expression);
     return this;
 }
예제 #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CouchQueryProvider"/> class.
 /// </summary>
 /// <param name="db">The db.</param>
 /// <param name="definition">The definition.</param>
 public CouchQueryProvider(ICouchDatabase db, ICouchViewDefinition definition)
 {
     this.db         = db;
     this.definition = definition;
 }
예제 #31
0
 public GenericDesignDocument(string name, ICouchDatabase db)
     : base(name, db)
 {
     Shows = new List<CouchFunctionDefinition>();
     Lists = new List<CouchFunctionDefinition>();
 }
예제 #32
0
 public async Task InitializeAsync()
 {
     _client = new CouchClient("http://localhost:5984", c =>
                               c.UseBasicAuthentication("admin", "admin"));
     _rebels = await _client.GetOrCreateDatabaseAsync <Rebel>();
 }
예제 #33
0
 public CouchDesignDocument(string documentId, ICouchDatabase owner)
     : base("_design/" + documentId)
 {
     Owner = owner;
 }
        public void ThenTheResultShouldBeTheDatabaseWasCreatedOnTheServer()
        {
            ICouchDatabase database = couchClient.GetDatabase(databaseName);

            Assert.That(databaseName, Is.EqualTo(database.Name));
        }
예제 #35
0
파일: Star.cs 프로젝트: Lemon30/spacegame
 /// <summary>
 /// Gathers all star object and return an iterator which
 /// iters thorough the star objects.
 /// </summary>
 /// <param name="dbObject">Database object generated by Divan</param>
 public void GetAllStars(ICouchDatabase dbObject)
 {
     starDBIter = dbObject.GetAllDocuments<StarInfo>();
 }
예제 #36
0
 public GenericDesignDocument(string name, ICouchDatabase db) : base(name, db)
 {
     Shows = new List <CouchFunctionDefinition>();
     Lists = new List <CouchFunctionDefinition>();
 }
예제 #37
0
 public CouchDB()
 {
     this.server   = new CouchServer("localhost", 5984);
     this.db       = server.GetDatabase("ticks");
     this.m_random = new Random(DateTime.Now.Millisecond);
 }
예제 #38
0
        public Find_Unsupported()
        {
            var client = new CouchClient("http://localhost");

            _rebels = client.GetDatabase <Rebel>();
        }
예제 #39
0
        public Find_Miscellaneous()
        {
            var client = new CouchClient("http://localhost");

            _rebels = client.GetDatabase <Rebel>();
        }
        public GetContinuousChangesAsync_Tests()
        {
            var client = new CouchClient("http://localhost");

            _rebels = client.GetDatabase <Rebel>();
        }
        public Find_Selector_Conditions()
        {
            var client = new CouchClient("http://localhost");

            _rebels = client.GetDatabase <Rebel>();
        }
예제 #42
0
 public virtual IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
 {
     return db.GetDocument<CouchDocument>(Id);
 }
예제 #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CouchQueryProvider"/> class.
 /// </summary>
 /// <param name="db">The db.</param>
 /// <param name="design">The design.</param>
 /// <param name="view">The view.</param>
 public CouchQueryProvider(ICouchDatabase db, string design, string view)
 {
     this.db     = db;
     this.view   = view;
     this.design = design;
 }
예제 #44
0
 public virtual IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
 {
     return(db.GetDocument <CouchDocument>(Id));
 }