コード例 #1
0
        public void JSON_OpenFileAndGatInformation_FileNotExist_FileNotFoundException()
        {
            string        Path       = @"Lala.txt";
            var           fileSystem = new MockFileSystem();
            IWorkWithFile file       = new FileWriterJSON(fileSystem, Path);

            Assert.Throws <FileNotFoundException>(() => file.OpenFileAndGatInformation());
        }
コード例 #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());
        }
コード例 #3
0
        public void JSON_OpenFileAndGatInformation_DeserializeJSONandGetInformationFromFile_ArraysAreSame()
        {
            // Dec
            string Path       = @"Resurses\MyTest.json";
            var    fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { Path, jsonForTest }
            });
            FileWriterJSON fileWeiter = new FileWriterJSON(fileSystem, Path);

            // Act
            PlaygroundArray arrayJsonSerialization = JsonConvert.DeserializeObject <PlaygroundArray>(jsonForTest);
            PlaygroundArray arrayFunctionTest      = (PlaygroundArray)fileWeiter.OpenFileAndGatInformation();

            //Assert
            Assert.Equal(arrayJsonSerialization.NumberOfArrays,
                         arrayFunctionTest.NumberOfArrays);
            Assert.Equal(arrayJsonSerialization.PlaygroundArrays[0].IterationNumber,
                         arrayFunctionTest.PlaygroundArrays[0].IterationNumber);
            Assert.Equal(arrayJsonSerialization.PlaygroundArrays[0].GetNumberOfLivePoints(),
                         arrayFunctionTest.PlaygroundArrays[0].GetNumberOfLivePoints());
            Assert.Equal(arrayJsonSerialization.PlaygroundArrays[0].GetPlaygroundArray(),
                         arrayFunctionTest.PlaygroundArrays[0].GetPlaygroundArray());
        }