Skip to content

Initializes Contact info array and set the language dependent attribute #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions PCAxis.Core.UnitTest/PxFileSerializerTest.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Imports System.IO
Imports System.Text
Imports Microsoft.VisualStudio.TestTools.UnitTesting
Imports PCAxis.Paxiom


<TestClass>
Public Class PxFileSerializerTest
<TestMethod>
Sub ShouldBeAbleToSerialize()

'Arrange
Dim pxModel As New PXModel()

Dim timeVar As New Variable("Period", PlacementType.Heading)
timeVar.IsTime = True
timeVar.Values.Add(New Value("2018M01"))

pxModel.Meta.AddVariable(timeVar)

Dim regionVar As New Variable("Region", PlacementType.Stub)
regionVar.IsTime = False
regionVar.Values.Add(New Value("A"))
regionVar.Values.Add(New Value("B"))

pxModel.Meta.AddVariable(regionVar)

pxModel.Meta.AxisVersion = "2018"
pxModel.Meta.Language = "en"
pxModel.Meta.SubjectArea = "TST"
pxModel.Meta.SubjectCode = "TST"
pxModel.Meta.Matrix = "TST01"
pxModel.Meta.Title = "Test data"
pxModel.Meta.Source = "PxTools"
pxModel.Meta.Contents = "Test data"
pxModel.Meta.Decimals = 0
pxModel.Meta.Description = "Test file"
pxModel.Meta.DescriptionDefault = False

Dim contentInfo As New ContInfo()
contentInfo.Units = "Amount"
pxModel.Meta.ContentInfo = contentInfo
pxModel.IsComplete = True

pxModel.Data.SetMatrixSize(1, 1)

pxModel.Data.WriteElement(0, 100)

'Act
'Get a UTF-32 encoding by name.
Dim serializer As PXFileSerializer = New PXFileSerializer()

serializer.Serialize(pxModel, Stream.Null)

'Assert
Try
serializer.Serialize(pxModel, Stream.Null)
'Assert
'If no exception is thrown, the test passes.
Assert.IsTrue(True)
Catch ex As Exception
'If an exception is thrown, the test fails.
Assert.Fail("Serialization threw an exception: " & ex.Message)
End Try

End Sub
End Class
3 changes: 2 additions & 1 deletion PCAxis.Core/PaxiOM/ContInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Namespace PCAxis.Paxiom
mContact = New String(0) {}
mUnits = New String(0) {}
mContact(0) = ""
mContactInfo = New List(Of Contact)() {}
mContactInfo = New List(Of Contact)(0) {}
End Sub

''' <summary>
Expand Down Expand Up @@ -81,6 +81,7 @@ Namespace PCAxis.Paxiom
Private mCFPrices As String
<LanguageDependent()>
Private mContact() As String
<LanguageDependent()>
Private mContactInfo() As List(Of Contact)
Private mLastUpdated As String
Private mRefPeriod As String
Expand Down
Loading