public void GetFileSize_returns_expected_size(string message) { using var file = new TinyMemoryMappedFile("Test"); var data = Encoding.UTF8.GetBytes(message); file.Write(data); file.GetFileSize().ShouldBe(message.Length); }
public void Write_then_read_returns_what_was_written(string message) { using var file = new TinyMemoryMappedFile("Test"); var data = Encoding.UTF8.GetBytes(message); file.Write(data); file.Read().ShouldBe(data); }
public void Secondary_instance_keeps_file_alive() { using var file2 = new TinyMemoryMappedFile("Test"); using (var file1 = new TinyMemoryMappedFile("Test")) { file1.Write(new byte[] { 1, 2, 3, 4, 5 }); } file2.GetFileSize().ShouldBe(5); }
public void Dispose_destroys_file() { using (var file = new TinyMemoryMappedFile("Test")) { file.Write(new byte[] { 1, 2, 3, 4, 5 }); } using (var file = new TinyMemoryMappedFile("Test")) { file.GetFileSize().ShouldBe(0); } }
public void Write_with_more_data_than_size_limit_throws() { using var file = new TinyMemoryMappedFile("Test", 4); Should.Throw <ArgumentOutOfRangeException>(() => file.Write(new byte[] { 1, 2, 3, 4, 5 })); }