public void NibeUnit_Refresh_Ok() { string fileContentExp = "{\"access_token\":\"AAEAAI3RKfqMqpUT6gPct8J4ysi2MvAITg9iJ - fydXOLDEP1DZ_9DbX3hh2Nw3DOydyc_IvBzNJW - k9uon0I4cxNuhhJJ5Z5OQEAUuB6er10aWLS7QnHAxvyAJFgsRUA9BBvmmA21MdBexw4JaKHaIswuxQwsOe3tBefPg8S_eEm44noPJIj_Zge4tgTZyTU1pIj5NksAm0T6i - tnf - wdrPg6AfWZHn1mNBBQnEosPNnq8OatCKK3CUunbCyNspB2v3p175WWSad2stb8Bo1nfvP8ZWebKIQFSYXNYLhYDd3T6EmxqVdIIj_Z6IFeqM4pTRndaIXrPdBCGRvNYCeA5puW2SkAQAAAAEAAB_Tqc5_JXDTzgaTS0amjWGCVvLo5ZV_5lIUMOxBfc7YlrLw0y2qhvUz3GwaMRx5WQdGdHhMkZpxzQPjiN - Zm2KGeyrTwFHj_fXFfxML3Gd_mQF5jrKmRcWwBXqTUDPwdOmPqXR94b6P4PqPzIXuoKvz_MRlrNfA1XmMCKagB8QsAdDmThu7QIR2gV5ENmJUcRHRY09XAAii4kYh6tyhvs8Zec7wgPRZ1Sq6aSOPYwdI3Ux3CRXUPgWxkGBbvCKPIu3keHJoZI - k1U81ha1AD5qj6RqMuM3m72VNXYuzSya62GfNP57BPupfgO_Igv9yWqf7jxPqy_XuAEYF0cNn5hAHDz3Kp9sRieCWW7fiiZwNghVp1 - jo_mdgyd1dPwqsh6UjOJqSuqWSEGWptpxZJ2bnB1akCmqpfKvgJgiV8Ilr68Tjw2uiMPGOlZF3b5T_uRszpTNFIfz4QpWdbbaHabeiBfit4oI3AqsCLEL3MU0W8Sk1QbxikEgON6v - 2lmkJ2t_iUGa3RXh3124QltUujywVVfeEJJupJjs1vRHZmD8\",\"token_type\":\"bearer\",\"expires_in\":1800,\"refresh_token\":\"8_Ln!IAAAAGQC4_hJShmgj10Be6CXXj6SJEJCobqeQMmvBdFp - flssQAAAAGiydTTibPGsB_03OYi - ASktAwRonG9sj0vHJpewUGGmGDxawAXVE4G5mpLHNcpezmDEFg2o3sXIRrdOlymY47itMwqTJyGCSxcoUw3OOVFiMA29VZWSTLjB_hCqMUhTTgxDAo1ykF - kjG - Q84X9xpdx1VEbyBK7LCMYR2h0fcrl0 - qV7MRAhJvKcy7YJ62CXfKm5Nq1PWJ4qTONFYRtL1Z5X8rJ_jLzLYFy3I4EykDqw\",\"scope\":\"READSYSTEM\"}"; ApiStub apiNibeStub = new ApiStub(); apiNibeStub.Post( "/oauth/token", (request, args) => { return(fileContentExp); } ); apiNibeStub.Start(); AppKeyConfig configs = new AppKeyConfig(); configs.NibeHost = apiNibeStub.Address; File.WriteAllText(codeFilePath, DateTime.Now.ToString()); NibeAuth res = nibeUnit.Refresh(configs); string resString = JsonConvert.SerializeObject(res); string fileContentAct = File.ReadAllText("data/nibeauth.json"); NibeAuth resFile = JsonConvert.DeserializeObject <NibeAuth>(fileContentExp); // Assert.Equal(fileContentExp, fileContentAct); Assert.Equal(fileContentExp, resString); }
public void NibeUnit_Refresh_NotOk() { ApiStub apiNibeStub = new ApiStub(); apiNibeStub.Request(HttpMethod.Post). IfRoute("/oauth/token"). Response((request, args) => { return("{ Error, Not Authorized}"); } ).StatusCode(StatusCodes.Status401Unauthorized); apiNibeStub.Start(); AppKeyConfig configs = new AppKeyConfig(); configs.NibeHost = apiNibeStub.Address; NibeAuth res = nibeUnit.Refresh(configs); Assert.Null(res); }