public void GetNumberOfLivingPlaygrounds_OnePlaygroundBacomeNullable_Ture() { IPlaygroundArray playgrounds = new PlaygroundArray(10, 10, 5); int[,] zerroArray = new int[10, 10] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }, }; for (int i = 0; i < playgrounds.NumberOfArrays; i++) { playgrounds.PlaygroundArrays[i].PlaygroundGrid = _arrayForTest; } Assert.Equal(5, playgrounds.GetNumberOfLivePlaygrounds()); playgrounds.PlaygroundArrays[0].PlaygroundGrid = zerroArray; Assert.Equal(4, playgrounds.GetNumberOfLivePlaygrounds()); }
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()); }
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()); }