public void Test_Issue99_v2_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/99
        {
            #region Arrange
            IArchiveConnector ac = new InboxConnector();

            var data           = Resource.fortnox_image;
            var randomFileName = TestUtils.RandomString() + ".txt";

            var fortnoxFile = ac.UploadFile(randomFileName, data, StaticFolders.SupplierInvoices);
            MyAssert.HasNoError(ac);

            #endregion Arrange

            var archiveConnector = new ArchiveConnector();
            var case1            = archiveConnector.DownloadFile(fortnoxFile.Id, IdType.Id);
            var case2            = archiveConnector.DownloadFile(fortnoxFile.Id, IdType.FileId);
            var case3            = archiveConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.Id);
            var case4            = archiveConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.FileId);

            Assert.IsNotNull(case1);
            Assert.IsNull(case2);
            Assert.IsNull(case3);
            Assert.IsNotNull(case4);

            var inboxConnector = new InboxConnector();
            var case5          = inboxConnector.DownloadFile(fortnoxFile.Id, IdType.Id);
            var case6          = inboxConnector.DownloadFile(fortnoxFile.Id, IdType.FileId);

            var case7 = inboxConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.Id);
            var case8 = inboxConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.FileId);

            Assert.IsNotNull(case5);
            Assert.IsNotNull(case6); //Why not null?
            Assert.IsNull(case7);
            Assert.IsNotNull(case8);

            //Clean
            inboxConnector.DeleteFile(fortnoxFile.Id);
            MyAssert.HasNoError(archiveConnector);
        }
Beispiel #2
0
        public void Test_Issue99_v2_fixed() // Origins from https://github.com/FortnoxAB/csharp-api-sdk/issues/99
        {
            #region Arrange
            IArchiveConnector ac = new InboxConnector();

            var data           = Resource.fortnox_image;
            var randomFileName = TestUtils.RandomString() + ".txt";

            var fortnoxFile = ac.UploadFile(randomFileName, data, StaticFolders.SupplierInvoices);

            #endregion Arrange

            var archiveConnector = new ArchiveConnector();
            var case1            = archiveConnector.DownloadFile(fortnoxFile.Id, IdType.Id);     //no error
            Assert.ThrowsException <FortnoxApiException>(
                () => archiveConnector.DownloadFile(fortnoxFile.Id, IdType.FileId));             //has error
            Assert.ThrowsException <FortnoxApiException>(
                () => archiveConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.Id));      //has error
            var case4 = archiveConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.FileId); //no error

            Assert.IsNotNull(case1);
            Assert.IsNotNull(case4);

            var inboxConnector = new InboxConnector();
            var case5          = inboxConnector.DownloadFile(fortnoxFile.Id, IdType.Id);       //no error
            var case6          = inboxConnector.DownloadFile(fortnoxFile.Id, IdType.FileId);   //no error, why?
            Assert.ThrowsException <FortnoxApiException>(
                () => inboxConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.Id));      //has error
            var case8 = inboxConnector.DownloadFile(fortnoxFile.ArchiveFileId, IdType.FileId); //no error

            Assert.IsNotNull(case5);
            Assert.IsNotNull(case6);
            Assert.IsNotNull(case8);

            //Clean
            inboxConnector.DeleteFile(fortnoxFile.Id);
        }