forked from dsolovay/AutoSitecore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DocumentationTest.cs
53 lines (48 loc) · 1.64 KB
/
DocumentationTest.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoSitecore;
using NSubstitute;
using Sitecore;
using Sitecore.Data;
using Sitecore.Data.Items;
using Xunit;
namespace AutoSitecoreUnitTest
{
public class DocumentationTest
{
[Theory, AutoSitecore]
public void CreateTestItem(Item item)
{
// Basic item values set up
Assert.NotNull(item);
Assert.NotEqual(item.ID, ID.Null);
Assert.NotEqual(item.TemplateID, ID.Null);
// NSubstitute features for all virtual fields
item.Name.Returns("some new name");
item.DidNotReceiveWithAnyArgs().Add("", new TemplateID());
}
[Theory, AutoSitecore]
public void CreateItemWithValues([ItemData(itemId:"{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}",
templateId:"{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}", name:"Home", fields:true)] Item item)
{
Assert.Equal(ID.Parse("{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}"), item.ID);
Assert.Equal(ID.Parse("{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}"), item.TemplateID);
Assert.Equal("Home", item.Name);
Assert.Equal("home", item.Key);
Assert.Equal(3, item.Fields.Count()); // Follows AutoFixture standard of creating three items.
// fields can be accessed on item or Fields collection
ID id = item.InnerData.Fields.GetFieldIDs().First();
string value = item.InnerData.Fields[id];
Assert.Equal(value, item[id]);
Assert.Equal(value, item.Fields[id].Value);
}
[Theory, AutoSitecore]
public void DatabaseIsSame(Item item, Database db)
{
Assert.Same(db, item.Database);
}
}
}