public void azSaveGame_ThrowArgumentNullException_IfFilenameIsWhiteSpaces()
        {
            var mockConfiguration = GetMockConfiguration();
            var azGameFileManager = new AzureGameFileManager(mockConfiguration);

            IGameDescriptor gameDescriptor = new GameDescriptor();
            string          fileName       = "   ";

            Assert.ThrowsException <ArgumentNullException>(() => azGameFileManager.SaveGame(gameDescriptor, fileName));
        }
        public void azSaveGame_ThrowArgumentNullException_IfGameIsNull()
        {
            //Arrange
            var mockConfiguration = GetMockConfiguration();

            var             azGameFileManager = new AzureGameFileManager(mockConfiguration);
            IGameDescriptor gameDescriptor    = null;
            string          fileName          = "newGame";

            //Act && Assert
            Assert.ThrowsException <ArgumentNullException>(() => azGameFileManager.SaveGame(gameDescriptor, fileName));
        }
Esempio n. 3
0
        public void IntegrationTest_SaveGame()
        {
            var mockConfiguration = GetMockConfiguration();
            var azGameFileManager = new AzureGameFileManager(mockConfiguration);

            var gameList0 = azGameFileManager.GetGameFiles().ToList();

            var descriptor     = azGameFileManager.ReadGame("mygame.xml");
            var newfileInAzure = azGameFileManager.SaveGame(descriptor, "SaveGameTest.xml");
            var gameList1      = azGameFileManager.GetGameFiles().ToList();

            azGameFileManager.DeleteGame("SaveGameTestTest.xml");

            var gameList2 = azGameFileManager.GetGameFiles().ToList();

            Assert.IsTrue(gameList1.Any(x => x.Name == "SaveGameTest.xml"));//TODO ASSERT
        }
Esempio n. 4
0
        public void IntegrationTest_GetGameFiles_v2()
        {
            var mockConfiguration = GetMockConfiguration();
            var azGameFileManager = new AzureGameFileManager(mockConfiguration);


            //azGameFileManager.DeleteGame(gameDetails[0].Name);
            var descriptor     = new GameDescriptor();
            var newfileInAzure = azGameFileManager.SaveGame(descriptor, "ListOfFilesTest.xml");

            var gameDetails0 = azGameFileManager.GetGameFiles().ToList();

            azGameFileManager.DeleteGame("ListOfFilesTest.xml");
            var gameDetails1 = azGameFileManager.GetGameFiles().ToList();

            Assert.IsTrue(gameDetails0.Any(x => x.Name == "ListOfFilesTest.xml"));
            Assert.IsFalse(gameDetails1.Any(x => x.Name == "ListOfFilesTest.xml"));
        }
        public void azSaveGame_CreatesFile_IfFilenameDoesntExists()
        {
            var mockConfiguration = GetMockConfiguration();
            var azGameFileManager = new AzureGameFileManager(mockConfiguration);

            IGameDescriptor gameDescriptor = new GameDescriptor();
            string          fileName       = "qsdfghjklm123456789.xml";

            //var mockFileSystem = new MockFileSystem();
            //GameFileManagerStatic.FileSystemDI = mockFileSystem;
            //var mockInputFile = new MockFileData("line1\nline2\nline3");

            //mockFileSystem.AddFile(Path.Combine(GameFileManagerStatic.GameFolder, fileName), mockInputFile);

            //int nbFileOccurences_beforeSave = GameFileManagerStatic.GetNumberOfFileIterations(fileName);

            string newFilePath = azGameFileManager.SaveGame(gameDescriptor, fileName);

            //int nbFileOccurences_afterSave = GameFileManagerStatic.GetNumberOfFileIterations(fileName);

            Assert.IsTrue(newFilePath.Length > 1);
        }