コード例 #1
0
        public void JSON_WriteInformationInFile_SerializateObjectAndSaveIt_JSONSAreSame()
        {
            GameEngine gameEngine = new GameEngine();
            string     Path       = @"Resurses\MyTest.json";
            var        fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { Path, "" }
            });
            IPlaygroundArray playgroundArr = JsonConvert.DeserializeObject <PlaygroundArray>(jsonForTest);

            IWorkWithFile file = new FileWriterJSON(fileSystem, Path);

            file.WriteInformationInFile(playgroundArr);
            string text = fileSystem.File.ReadAllText(Path);

            Assert.Equal(text, jsonForTest);
        }
コード例 #2
0
        public void JSON_CreateSaveDownload_CreateClassSaveItAndDownloadFromFile_True()
        {
            IPlaygroundArray expectedArray = new PlaygroundArray(10, 10, 1);
            string           Path          = @"Resurses\MyTest.json";
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { Path, "" }
            });
            IWorkWithFile file = new FileWriterJSON(fileSystem, Path);

            file.WriteInformationInFile(expectedArray);
            IPlaygroundArray actualArray = file.OpenFileAndGatInformation();

            Assert.Equal(expectedArray.NumberOfArrays,
                         actualArray.NumberOfArrays);
            Assert.Equal(expectedArray.PlaygroundArrays[0].IterationNumber,
                         actualArray.PlaygroundArrays[0].IterationNumber);
            Assert.Equal(expectedArray.PlaygroundArrays[0].GetNumberOfLivePoints(),
                         actualArray.PlaygroundArrays[0].GetNumberOfLivePoints());
            Assert.Equal(expectedArray.PlaygroundArrays[0].GetPlaygroundArray(),
                         actualArray.PlaygroundArrays[0].GetPlaygroundArray());
        }