public void Init_WithDefaultSettings_ShouldSameAsDefault()
		{
			ArangoClient client = new ArangoClient();

			client.Init();

			Assert.Same(client.Settings, ArangoClientSettings.Default);
		}
Esempio n. 2
0
        public void Init_WithDefaultSettings_ShouldSameAsDefault()
        {
            ArangoClient client = new ArangoClient();

            client.Init();

            Assert.Same(client.Settings, ArangoClientSettings.Default);
        }
        public TestCaseWithClient()
        {
            LogManager.SetFactory(new ConsoleLoggerFactory());

            Logger = LogManager.GetLogger("Tests");

            Client = new ArangoClient();

            Client.Init();
        }
		public TestCaseWithClient()
		{
			LogManager.SetFactory(new ConsoleLoggerFactory());

			Logger = LogManager.GetLogger("Tests");

			Client = new ArangoClient();

			Client.Init();
		}
Esempio n. 5
0
        public void Dispatch_ThrowExceptionsFalse_NotThrowException()
        {
            using (ArangoClient client = new ArangoClient())
            {
                client.Init();

                var response = client.Database.Drop(ArangoConventions.SystemDatabase);

                response.AssertFail();
            }
        }
		public void Dispatch_ThrowExceptionsFalse_NotThrowException()
		{
			using (ArangoClient client = new ArangoClient())
			{
				client.Init();

				var response = client.Database.Drop(ArangoConventions.SystemDatabase);

				response.AssertFail();
			}
		}
Esempio n. 7
0
        public void Dispatch_ThrowExceptionsTrue_ShouldThrowException()
        {
            using (ArangoClient client = new ArangoClient())
            {
                client.Init(new ArangoClientSettings
                {
                    ThrowExceptions = true
                });

                Assert.Throws <ArangoException>(() => client.Database.Drop(ArangoConventions.SystemDatabase));
            }
        }
		public void Dispatch_ThrowExceptionsTrue_ShouldThrowException()
		{
			using (ArangoClient client = new ArangoClient())
			{
				client.Init(new ArangoClientSettings
				{
					ThrowExceptions = true
				});

				Assert.Throws<ArangoException>(() => client.Database.Drop(ArangoConventions.SystemDatabase));
			}
		}
Esempio n. 9
0
        public void Init_WithSpecificSettings_ShouldNotEqual()
        {
            ArangoClient client = new ArangoClient();

            client.Init(new ArangoClientSettings
            {
                Hostname = "localhost",
                Port     = 8529
            });

            Assert.NotSame(ArangoClientSettings.Default, client.Settings);
            Assert.Equal("localhost", client.Settings.Hostname);
            Assert.Equal(8529, client.Settings.Port);
        }
		public void Init_WithSpecificSettings_ShouldNotEqual()
		{
			ArangoClient client = new ArangoClient();

			client.Init(new ArangoClientSettings
			{
				Hostname = "localhost",
				Port = 8529
			});

			Assert.NotSame(ArangoClientSettings.Default, client.Settings);
			Assert.Equal("localhost", client.Settings.Hostname);
			Assert.Equal(8529, client.Settings.Port);
		}
        public void SimpleUsage()
        {
            using (var client = new ArangoClient())
            {
                // Init the client, is possible to define settings like host/port
                client.Init();

                // Create new database
                client.Database.Create("ApiTests");

                // Scope to the recently created database
                using (var db = client.UseDatabase("ApiTests"))
                {
                    // Create Station document collection
                    db.Collection.Create("Station");

                    // Create a station with key ZEK
                    var stationZEK = new JObject
                    {
                        { "_key", "ZEK" },
                        { "Name", "ZEK" },
                        { "Capacity", 2 }
                    };

                    // All operations return ArangoResponse generic type
                    ArangoResponse <JObject> createResult = db.Document.Create(stationZEK, "Station");

                    // By default, this API doesn't throws a Exception if an operation fail,
                    // always is good check the Status.Error property.
                    // This behavior can be configured in ArangoClientSettings.ThrowExceptions
                    if (createResult.Status.Error)
                    {
                        throw new Exception(createResult.Status.ErrorMessage);
                    }

                    // Or just call the ThrowIfError() method
                    createResult.ThrowIfError();

                    // Status has other details
                    // https://www.arangodb.org/manuals/current/ImplementorManualArangoErrors.html
                    int            errorNum       = createResult.Status.ErrorNum;
                    int            code           = createResult.Status.Code;
                    HttpStatusCode httpStatusCode = createResult.Status.StatusCode;
                    TimeSpan       totalDuration  = createResult.Status.TotalDuration;
                    TimeSpan       serverDuration = createResult.Status.ServerDuration;

                    // Each operation have a type of result
                    JObject resultOfOperation = createResult.Result;

                    // Create the main line of ZEK station
                    var lineZEK1 = new JObject
                    {
                        { "Name", "ZEK1" },
                        { "MainLine", true }
                    };

                    // Is possible to use the SetKey extension method to set the _key
                    lineZEK1.SetKey("ZEK1");

                    // Are possible to create collections on the fly
                    db.Document.Create(lineZEK1, "Line", createCollection: true);

                    // Now, we create the edge collection to link Station with Lines
                    db.Collection.Create("Station-Line", CollectionType.Edge);

                    // Create the edge to link ZEK station with ZEK1 line
                    db.Edge.Create("Station-Line", "Station/ZEK", "Line/ZEK1", "ZEK-ZEK1");
                }

                // To finalize the test, drop the database
                client.Database.Drop("ApiTests");
            }
        }
		public void SimpleUsage()
		{
			using (var client = new ArangoClient())
			{
				// Init the client, is possible to define settings like host/port
				client.Init();

				// Create new database
				client.Database.Create("ApiTests");

				// Scope to the recently created database
				using (var db = client.UseDatabase("ApiTests"))
				{
					// Create Station document collection
					db.Collection.Create("Station");

					// Create a station with key ZEK
					var stationZEK = new JObject
					{
						{ "_key", "ZEK" },
						{ "Name", "ZEK" },
						{ "Capacity", 2 }
					};

					// All operations return ArangoResponse generic type
					ArangoResponse<JObject> createResult = db.Document.Create(stationZEK, "Station");

					// By default, this API doesn't throws a Exception if an operation fail, 
					// always is good check the Status.Error property. 
					// This behavior can be configured in ArangoClientSettings.ThrowExceptions
					if (createResult.Status.Error)
					{
						throw new Exception(createResult.Status.ErrorMessage);
					}

					// Or just call the ThrowIfError() method
					createResult.ThrowIfError();

					// Status has other details
					// https://www.arangodb.org/manuals/current/ImplementorManualArangoErrors.html
					int errorNum = createResult.Status.ErrorNum;
					int code = createResult.Status.Code;
					HttpStatusCode httpStatusCode = createResult.Status.StatusCode;
					TimeSpan totalDuration = createResult.Status.TotalDuration;
					TimeSpan serverDuration = createResult.Status.ServerDuration;

					// Each operation have a type of result
					JObject resultOfOperation = createResult.Result;

					// Create the main line of ZEK station
					var lineZEK1 = new JObject
					{
						{"Name", "ZEK1"},
						{"MainLine", true}
					};

					// Is possible to use the SetKey extension method to set the _key
					lineZEK1.SetKey("ZEK1");

					// Are possible to create collections on the fly
					db.Document.Create(lineZEK1, "Line", createCollection: true);

					// Now, we create the edge collection to link Station with Lines
					db.Collection.Create("Station-Line", CollectionType.Edge);

					// Create the edge to link ZEK station with ZEK1 line
					db.Edge.Create("Station-Line", "Station/ZEK", "Line/ZEK1", "ZEK-ZEK1");
				}

				// To finalize the test, drop the database
				client.Database.Drop("ApiTests");
			}
		}