public void GetKey()
        {
            var auth = new OpenAI_API.APIAuthentication("pk-testAA");

            Assert.IsNotNull(auth.ApiKey);
            Assert.AreEqual("pk-testAA", auth.ApiKey);
        }
Beispiel #2
0
        public void GetKey()
        {
            var auth = new OpenAI_API.APIAuthentication("pk-testAA", "sk-testBB");

            Assert.IsNotNull(auth.GetKey());
            Assert.AreEqual("sk-testBB", auth.GetKey());

            auth = new OpenAI_API.APIAuthentication("pk-testAA", null);
            Assert.IsNotNull(auth.GetKey());
            Assert.AreEqual("pk-testAA", auth.GetKey());
        }
        public void ParseKey()
        {
            var auth = new OpenAI_API.APIAuthentication("pk-testAA");

            Assert.IsNotNull(auth.ApiKey);
            Assert.AreEqual("pk-testAA", auth.ApiKey);
            auth = "pk-testCC";
            Assert.IsNotNull(auth.ApiKey);
            Assert.AreEqual("pk-testCC", auth.ApiKey);

            auth = new OpenAI_API.APIAuthentication("sk-testBB");
            Assert.IsNotNull(auth.ApiKey);
            Assert.AreEqual("sk-testBB", auth.ApiKey);
        }
        public void testHelper()
        {
            OpenAI_API.APIAuthentication defaultAuth         = OpenAI_API.APIAuthentication.Default;
            OpenAI_API.APIAuthentication manualAuth          = new OpenAI_API.APIAuthentication("pk-testAA");
            OpenAI_API.OpenAIAPI         api                 = new OpenAI_API.OpenAIAPI();
            OpenAI_API.APIAuthentication shouldBeDefaultAuth = api.Auth;
            Assert.IsNotNull(shouldBeDefaultAuth);
            Assert.IsNotNull(shouldBeDefaultAuth.ApiKey);
            Assert.AreEqual(defaultAuth.ApiKey, shouldBeDefaultAuth.ApiKey);

            OpenAI_API.APIAuthentication.Default = new OpenAI_API.APIAuthentication("pk-testAA");
            api = new OpenAI_API.OpenAIAPI();
            OpenAI_API.APIAuthentication shouldBeManualAuth = api.Auth;
            Assert.IsNotNull(shouldBeManualAuth);
            Assert.IsNotNull(shouldBeManualAuth.ApiKey);
            Assert.AreEqual(manualAuth.ApiKey, shouldBeManualAuth.ApiKey);
        }