Read SIF data from file
Write data to a SIN file, then export the file to SIF file format.
using System;
using NUnit.Framework;
namespace DNV.Sesam.SifApi.IO.Doc
{
public partial class ISifDataWriterTests
{
[Test]
public void WriteSINFileExportToSIF()
{
var randomFileNameSIN = Guid.NewGuid().ToString() + ".SIN";
using (var writer = SesamDataFactory.CreateWriter(randomFileNameSIN))
{
Assert.IsTrue(writer.CreateTab("HIERARCH", new long[] { 1 }, 1));
writer.Write("HIERARCH", new double[] { 8, 1, 1, 1, 1, 0, 0, 0 });
Assert.IsTrue(writer.CreateTab("IDENT", new long[] { 1 }, 1));
writer.Write("IDENT", new double[] { 1, 1, 3 });
// The maximum id is 99, but only 5 data sets are written
Assert.IsTrue(writer.CreateTab("GBEAMG", new long[] { 99 },5));
// Note that the first entry is always the length of the written
// data array, also for datatypes which do not have the length of
// the data as the first entry according to the SIF datatype
// definition
writer.Write("GBEAMG", new double[] { 17, 1, 0,
8.79331768E-01, 2.12802696E+00,1.06401348E+00, 1.06401348E+00,
0, 1.33001685E+00, 6.65008426E-01, 6.65008426E-01, 4.39911306E-01,
4.39911306E-01,0,0, 4.35366005E-01, 4.35366005E-01});
writer.Write("GBEAMG", new double[] { 17, 2, 0,
8.79331768E-01, 2.12802696E+00, 1.06401348E+00, 1.06401348E+00,
0, 1.33001685E+00, 6.65008426E-01, 6.65008426E-01, 4.39911306E-01,
4.39911306E-01, 0, 0, 4.35366005E-01, 4.35366005E-01 });
writer.Write("GBEAMG", new double[] { 17, 3, 0,
8.79331768E-01, 2.12802696E+00, 1.06401348E+00, 1.06401348E+00,
0, 1.33001685E+00, 6.65008426E-01, 6.65008426E-01, 4.39911306E-01,
4.39911306E-01, 0, 0, 4.35366005E-01, 4.35366005E-01 });
writer.Write("GBEAMG", new double[] { 17, 98, 0,
8.79331768E-01, 2.12802696E+00, 1.06401348E+00, 1.06401348E+00,
0, 1.33001685E+00, 6.65008426E-01, 6.65008426E-01, 4.39911306E-01,
4.39911306E-01, 0, 0, 4.35366005E-01, 4.35366005E-01 });
writer.Write("GBEAMG", new double[] { 17, 99, 0,
8.79331768E-01, 2.12802696E+00, 1.06401348E+00, 1.06401348E+00,
0, 1.33001685E+00, 6.65008426E-01, 6.65008426E-01, 4.39911306E-01,
4.39911306E-01, 0, 0, 4.35366005E-01, 4.35366005E-01 });
var randomFileNameSIF = Guid.NewGuid().ToString() + ".SIF";
writer.WriteSifFile(randomFileNameSIF);
Assert.IsTrue(System.IO.File.Exists(randomFileNameSIF));
System.IO.File.Delete(randomFileNameSIF);
}
System.IO.File.Delete(randomFileNameSIN);
}
}
}