コード例 #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
ファイル: CouchLuceneTest.cs プロジェクト: kolosy/Divan
 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
ファイル: CouchContext.cs プロジェクト: cole124/couchdb-net
        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
ファイル: CouchLinqTest.cs プロジェクト: vchyzhevskyi/Divan
        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
ファイル: Program.cs プロジェクト: nim-ohtar/TelerikAcademy-2
        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
ファイル: Program.cs プロジェクト: nim-ohtar/TelerikAcademy-2
        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
ファイル: Program.cs プロジェクト: nim-ohtar/TelerikAcademy-2
 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
ファイル: GameMaster.cs プロジェクト: Lemon30/spacegame
	// 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
ファイル: ExpressionVisitor.cs プロジェクト: grueni/Divan
        /// <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
ファイル: CouchAutoreconcileTest.cs プロジェクト: nseba/Divan
 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;
                }
            }
        }
コード例 #28
0
 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
ファイル: CouchQueryProvider.cs プロジェクト: mgornik/Divan
 /// <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
ファイル: CouchDB.cs プロジェクト: gboillet/Benchmark-NoSQL
 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>();
        }
コード例 #40
0
        public GetContinuousChangesAsync_Tests()
        {
            var client = new CouchClient("http://localhost");

            _rebels = client.GetDatabase <Rebel>();
        }
コード例 #41
0
        public Find_Selector_Conditions()
        {
            var client = new CouchClient("http://localhost");

            _rebels = client.GetDatabase <Rebel>();
        }
コード例 #42
0
ファイル: CouchDocument.cs プロジェクト: kolosy/Divan
 public virtual IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
 {
     return db.GetDocument<CouchDocument>(Id);
 }
コード例 #43
0
ファイル: CouchQueryProvider.cs プロジェクト: mgornik/Divan
 /// <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
ファイル: CouchDocument.cs プロジェクト: grueni/Divan
 public virtual IReconcilingDocument GetDatabaseCopy(ICouchDatabase db)
 {
     return(db.GetDocument <CouchDocument>(Id));
 }