public void TestElasticsearchSource_HandlesType_ExpectName()
        {
            //------------Setup for test--------------------------
            var testElasticsearchSource = new TestElasticsearchSource();

            //------------Execute Test---------------------------
            //------------Assert Results-------------------------
            Assert.AreEqual("TestElasticsearchSource", testElasticsearchSource.HandlesType());
        }
        public void testElasticsearchSource_GetAuthorizationContextForService_ShouldReturnContext()
        {
            //------------Setup for test--------------------------
            var testElasticsearchSource = new TestElasticsearchSource();
            //------------Execute Test---------------------------
            var resId = testElasticsearchSource.GetAuthorizationContextForService();

            //------------Assert Results-------------------------
            Assert.AreEqual(AuthorizationContext.Contribute, resId);
        }
        public void TestElasticsearchSource_GetResourceID_ShouldReturnEmptyGuid()
        {
            //------------Setup for test--------------------------
            var testElasticsearchSource = new TestElasticsearchSource();
            //------------Execute Test---------------------------
            var resId = testElasticsearchSource.GetResourceID(new Dictionary <string, StringBuilder>());

            //------------Assert Results-------------------------
            Assert.AreEqual(Guid.Empty, resId);
        }
        public void TestElasticsearchSource_CreateServiceEntry_ExpectActions()
        {
            //------------Setup for test--------------------------
            var testElasticsearchSource = new TestElasticsearchSource();
            //------------Execute Test---------------------------
            var dynamicService = testElasticsearchSource.CreateServiceEntry();

            //------------Assert Results-------------------------
            Assert.IsNotNull(dynamicService);
            Assert.IsNotNull(dynamicService.Actions);
        }
        public void TestElasticsearchSource_Execute_NullValues_ErrorResult()
        {
            //------------Setup for test--------------------------
            var testElasticsearchSource = new TestElasticsearchSource();
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            var jsonResult = testElasticsearchSource.Execute(null, null);
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsTrue(result.HasError);
        }
        public void TestElasticsearchSource_Execute_ResourceIDNotPresent_ErrorResult()
        {
            //------------Setup for test--------------------------
            var values = new Dictionary <string, StringBuilder> {
                { "item", new StringBuilder() }
            };
            var testElasticsearchSource = new TestElasticsearchSource();
            var serializer = new Dev2JsonSerializer();
            //------------Execute Test---------------------------
            var jsonResult = testElasticsearchSource.Execute(values, null);
            var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);

            //------------Assert Results-------------------------
            Assert.IsTrue(result.HasError);
        }
        public void TestElasticsearchSource_Execute_Auth_Password_GivenResourceDefinition_ShouldTestNewSourceReturnResourceDefinitionMsg()
        {
            //---------------Set up test pack-------------------
            var serializer = new Dev2JsonSerializer();
            var dependency = new Depends(Depends.ContainerType.AnonymousElasticsearch);
            var hostName   = "http://" + dependency.Container.IP;
            var source     = new ElasticsearchSourceDefinition()
            {
                Id                 = Guid.Empty,
                Name               = "Name",
                HostName           = hostName,
                Port               = dependency.Container.Port,
                Username           = "******",
                Password           = "******",
                SearchIndex        = "warewolftestlogs",
                AuthenticationType = Dev2.Runtime.ServiceModel.Data.AuthenticationType.Password
            };
            var testElasticsearchSource = new TestElasticsearchSource();
            var values = new Dictionary <string, StringBuilder>
            {
                { "ElasticsearchSource", source.SerializeToJsonStringBuilder() }
            };

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            try
            {
                var jsonResult = testElasticsearchSource.Execute(values, null);
                var result     = serializer.Deserialize <ExecuteMessage>(jsonResult);
                //---------------Test Result -----------------------
                Assert.IsFalse(result.HasError, result.Message.ToString());
            }
            catch (Exception e)
            {
                if (e.Message.Contains("could not connect to elasticsearch Instance"))
                {
                    Assert.Inconclusive(e.Message);
                }
                else
                {
                    throw;
                }
            }
        }