public async Task SaveSheet_WhenDataIsValid_Saves()
        {
            // arrange
            var valueRange = new ValueRange
            {
                Values = new List <IList <object> >
                {
                    new List <object> {
                        "ID", "ru", "en", "ua"
                    },
                    new List <object> {
                        "btn.Word", "Слово", "word"
                    },
                    new List <object> {
                        "btn.Work", "Работа", "work"
                    },
                    new List <object> {
                        "Work", "Работа", "work"
                    }
                }
            };

            var expectedI18nSheet = new I18nSheet("spreadsheetId1", "sheetName1", valueRange);
            var i18nLocalStore    = new I18nLocalStore(Path.GetRandomFileName());

            // act
            await i18nLocalStore.SaveSheet(expectedI18nSheet);

            // assert
            var storedSheet = await i18nLocalStore.GetSheet(expectedI18nSheet.SpreadsheetId, expectedI18nSheet.SheetName);

            Assert.AreEqual(expectedI18nSheet.SpreadsheetId, storedSheet.SpreadsheetId);
            Assert.AreEqual(expectedI18nSheet.SheetName, storedSheet.SheetName);
            Assert.AreEqual(expectedI18nSheet.ValueRange.Values, storedSheet.ValueRange.Values);
        }
Beispiel #2
0
        public async Task GetSheet_WhenSheetNameIsEmptyAndLangIsEn_ReturnsDataOfFirstSheet()
        {
            // arrange
            var i18nLocalStore = new I18nLocalStore(System.IO.Path.GetRandomFileName());
            await i18nLocalStore.SaveSheets(_sheets);

            // act & assert
            Assert.ThrowsAsync <ArgumentNullException>(
                async() => await i18nLocalStore.GetSheet(_spreadsheetId, "")
                );
        }
Beispiel #3
0
        public async Task GetSheet_WhenSheetNameIsUnknown_ReturnsNull()
        {
            // arrange
            var i18nLocalStore = new I18nLocalStore(System.IO.Path.GetRandomFileName());
            await i18nLocalStore.SaveSheets(_sheets);

            // act
            var sheet = await i18nLocalStore.GetSheet(_spreadsheetId, "NonExistingSheetName");

            // assert
            Assert.IsNull(sheet);
        }
Beispiel #4
0
        public async Task GetSheet_WhenLangIsEn_ReturnsEnglishData()
        {
            // arrange
            var i18nLocalStore = new I18nLocalStore(System.IO.Path.GetRandomFileName());
            await i18nLocalStore.SaveSheets(_sheets);

            // act
            var i18nSheet = await i18nLocalStore.GetSheet(_spreadsheetId, "Global");

            // assert
            var objectTree = i18nSheet.GetTranslations("en");

            Assert.AreEqual("Home", objectTree.GetOrCreateScope("navbar")["home"].ToString());
        }