Skip to content

Commit a8c48f5

Browse files
committed
Chore: Moved tests
1 parent 4b8d91e commit a8c48f5

File tree

2 files changed

+38
-19
lines changed

2 files changed

+38
-19
lines changed

PhpSerializerNET.Test/SerializeObjects.cs renamed to PhpSerializerNET.Test/Serialize/ListSerialization.cs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,36 +6,28 @@ This Source Code Form is subject to the terms of the Mozilla Public
66

77
using System.Collections.Generic;
88
using Microsoft.VisualStudio.TestTools.UnitTesting;
9-
using PhpSerializerNET.Test.DataTypes;
109

11-
namespace PhpSerializerNET.Test {
10+
namespace PhpSerializerNET.Test.Serialize {
1211
[TestClass]
13-
public class SerializeObjects {
12+
public class ListSerializationTest {
1413
[TestMethod]
15-
public void ExplicitToClassWithMappingAttributes() {
16-
var testObject = new MappedClass() {
17-
English = "Hello world!",
18-
German = "Hallo Welt!",
19-
It = "Ciao mondo!"
20-
};
21-
22-
Assert.AreEqual(
23-
"a:3:{s:2:\"en\";s:12:\"Hello world!\";s:2:\"de\";s:11:\"Hallo Welt!\";s:4:\"Guid\";a:1:{s:5:\"Empty\";N;}}",
24-
PhpSerialization.Serialize(testObject)
25-
);
26-
}
27-
28-
29-
[TestMethod]
30-
public void SerializeList() {
14+
public void SerializeListOfStrings() {
3115
Assert.AreEqual( // strings:
3216
"a:2:{i:0;s:5:\"Hello\";i:1;s:5:\"World\";}",
3317
PhpSerialization.Serialize(new List<string>() { "Hello", "World" })
3418
);
19+
}
20+
21+
[TestMethod]
22+
public void SerializeListOfBools() {
3523
Assert.AreEqual( // booleans:
3624
"a:2:{i:0;b:1;i:1;b:0;}",
3725
PhpSerialization.Serialize(new List<object>() { true, false })
3826
);
27+
}
28+
29+
[TestMethod]
30+
public void SerializeMixedList() {
3931
Assert.AreEqual( // mixed types:
4032
"a:5:{i:0;b:1;i:1;i:1;i:2;d:1.23;i:3;s:3:\"end\";i:4;N;}",
4133
PhpSerialization.Serialize(new List<object>() { true, 1, 1.23, "end", null })

PhpSerializerNET.Test/Serialize/ObjectSerialization.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,32 @@ public void SerializesToSpecificClass() {
3434
PhpSerialization.Serialize(testObject)
3535
);
3636
}
37+
38+
[TestMethod]
39+
public void SerializeObjectToArray() {
40+
var testObject = new MappedClass() {
41+
English = "Hello world!",
42+
German = "Hallo Welt!",
43+
It = "Ciao mondo!"
44+
};
45+
46+
Assert.AreEqual(
47+
"a:3:{s:2:\"en\";s:12:\"Hello world!\";s:2:\"de\";s:11:\"Hallo Welt!\";s:4:\"Guid\";a:1:{s:5:\"Empty\";N;}}",
48+
PhpSerialization.Serialize(testObject)
49+
);
50+
}
51+
52+
[TestMethod]
53+
public void SerializeObjectToObject() {
54+
var testObject = new UnnamedClass() {
55+
Foo = 1,
56+
Bar = 2,
57+
};
58+
59+
Assert.AreEqual(
60+
"O:8:\"stdClass\":2:{s:3:\"Foo\";d:1;s:3:\"Bar\";d:2;}",
61+
PhpSerialization.Serialize(testObject)
62+
);
63+
}
3764
}
3865
}

0 commit comments

Comments
 (0)