Esempio n. 1
0
 private MemberGroup BuildMemberGroup() =>
 _builder
 .WithId(6)
 .WithKey(Guid.NewGuid())
 .WithName("Test Group")
 .WithCreatorId(4)
 .WithCreateDate(DateTime.Now)
 .WithUpdateDate(DateTime.Now)
 .AddAdditionalData()
 .WithKeyValue("test1", 123)
 .WithKeyValue("test2", "hello")
 .Done()
 .Build();
Esempio n. 2
0
    public void Is_Built_Correctly()
    {
        // Arrange
        const int    testId              = 6;
        const string testName            = "Test Group";
        const int    testCreatorId       = 4;
        var          testKey             = Guid.NewGuid();
        var          testCreateDate      = DateTime.Now.AddHours(-1);
        var          testUpdateDate      = DateTime.Now;
        var          testAdditionalData1 = new KeyValuePair <string, object>("test1", 123);
        var          testAdditionalData2 = new KeyValuePair <string, object>("test2", "hello");

        var builder = new MemberGroupBuilder();

        // Act
        var group = builder
                    .WithId(testId)
                    .WithKey(testKey)
                    .WithName(testName)
                    .WithCreatorId(testCreatorId)
                    .WithCreateDate(testCreateDate)
                    .WithUpdateDate(testUpdateDate)
                    .AddAdditionalData()
                    .WithKeyValue(testAdditionalData1.Key, testAdditionalData1.Value)
                    .WithKeyValue(testAdditionalData2.Key, testAdditionalData2.Value)
                    .Done()
                    .Build();

        // Assert
        Assert.AreEqual(testId, group.Id);
        Assert.AreEqual(testKey, group.Key);
        Assert.AreEqual(testName, group.Name);
        Assert.AreEqual(testCreateDate, group.CreateDate);
        Assert.AreEqual(testUpdateDate, group.UpdateDate);
        Assert.AreEqual(testCreatorId, group.CreatorId);

        // previousName is added as part of the MemberGroup construction, plus the 2 we've added.
        Assert.AreEqual(3, group.AdditionalData.Count);
        Assert.AreEqual(testAdditionalData1.Value, group.AdditionalData[testAdditionalData1.Key]);
        Assert.AreEqual(testAdditionalData2.Value, group.AdditionalData[testAdditionalData2.Key]);
    }