Skip to content

Commit 5d37a86

Browse files
Cleanup
- Enable warnings as errors - Remove unused code - Add comments to tests
1 parent ccae87e commit 5d37a86

File tree

9 files changed

+25
-57
lines changed

9 files changed

+25
-57
lines changed

src/Web/Models/Media/GenericMedia.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ public class GenericMedia : MediaData
66
/// <summary>
77
/// Gets or sets the description.
88
/// </summary>
9-
public virtual String Description { get; set; }
9+
public virtual string Description { get; set; } = null!;
1010
}

src/Web/Models/Media/ImageFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public class ImageFile : ImageData
1212
/// <value>
1313
/// The copyright.
1414
/// </value>
15-
public virtual string Copyright { get; set; }
15+
public virtual string Copyright { get; set; } = null!;
1616
}

src/Web/Models/Media/VideoFile.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ public class VideoFile : VideoData
1111
/// <summary>
1212
/// Gets or sets the copyright.
1313
/// </summary>
14-
public virtual string Copyright { get; set; }
14+
public virtual string Copyright { get; set; } = null!;
1515

1616
/// <summary>
1717
/// Gets or sets the URL to the preview image.
1818
/// </summary>
1919
[UIHint(UIHint.Image)]
20-
public virtual ContentReference PreviewImage { get; set; }
20+
public virtual ContentReference PreviewImage { get; set; } = null!;
2121
}

src/Web/Models/Pages/NewsPage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
DisplayName = "News Page")]
66
public class NewsPage : PageData
77
{
8-
public virtual string Title { get; set; }
8+
public virtual string Title { get; set; } = null!;
99
}

src/Web/Models/Pages/StartPage.cs

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,17 @@
11
using System.ComponentModel.DataAnnotations;
22

33
namespace Optimizely.TestContainers.Models.Pages;
4-
//using AlloyTemplates.Models.Blocks;
54

65
/// <summary>
76
/// Used for the site's start page and also acts as a container for site settings
87
/// </summary>
98
[ContentType(
10-
GUID = "19671657-B684-4D95-A61F-8DD4FE60D559"
11-
/*GroupName = Global.GroupNames.Specialized*/)]
12-
//[SiteImageUrl]
13-
/*
14-
[AvailableContentTypes(
15-
Availability.Specific,
16-
Include = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage), typeof(ContentFolder) }, // Pages we can create under the start page...
17-
ExcludeOn = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage) })] // ...and underneath those we can't create additional start pages
18-
*/
9+
GUID = "19671657-B684-4D95-A61F-8DD4FE60D559")]
1910
public class StartPage : PageData
2011
{
2112
[Display(
2213
GroupName = SystemTabNames.Content,
2314
Order = 320)]
2415
[CultureSpecific]
25-
public virtual ContentArea MainContentArea { get; set; }
26-
27-
/*
28-
[Display(GroupName = Global.GroupNames.SiteSettings, Order = 300)]
29-
public virtual LinkItemCollection ProductPageLinks { get; set; }
30-
31-
[Display(GroupName = Global.GroupNames.SiteSettings, Order = 350)]
32-
public virtual LinkItemCollection CompanyInformationPageLinks { get; set; }
33-
34-
[Display(GroupName = Global.GroupNames.SiteSettings, Order = 400)]
35-
public virtual LinkItemCollection NewsPageLinks { get; set; }
36-
37-
[Display(GroupName = Global.GroupNames.SiteSettings, Order = 450)]
38-
public virtual LinkItemCollection CustomerZonePageLinks { get; set; }
39-
40-
[Display(GroupName = Global.GroupNames.SiteSettings)]
41-
public virtual PageReference GlobalNewsPageLink { get; set; }
42-
43-
[Display(GroupName = Global.GroupNames.SiteSettings)]
44-
public virtual PageReference ContactsPageLink { get; set; }
45-
46-
[Display(GroupName = Global.GroupNames.SiteSettings)]
47-
public virtual PageReference SearchPageLink { get; set; }
48-
49-
[Display(GroupName = Global.GroupNames.SiteSettings)]
50-
public virtual SiteLogotypeBlock SiteLogotype { get; set; }
51-
*/
16+
public virtual ContentArea MainContentArea { get; set; } = null!;
5217
}

src/Web/Optimizely.TestContainers.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
<Nullable>enable</Nullable>
55
<ImplicitUsings>enable</ImplicitUsings>
66
</PropertyGroup>
7+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
8+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
9+
</PropertyGroup>
10+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
11+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
12+
</PropertyGroup>
713

814
<ItemGroup>
915
<Using Include="EPiServer" />

test/OptimizelyTestContainers.Tests/NewsPageIntegrationTests.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,31 @@ public void Can_Create_And_Read_NewsPage()
2020
// Import test data
2121
var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!;
2222
var episerverDataFile = Path.Combine(basePath, "DefaultSiteContent.episerverdata");
23-
2423
var dataImporter = Services.GetRequiredService<OptimizelyDataImporter>();
2524
dataImporter.Import(episerverDataFile);
2625

27-
2826
// Find StartPage from root
29-
// Setup site definition
30-
3127
var startPage = repo.GetChildren<StartPage>(ContentReference.RootPage).First();
3228

29+
// Setup site definition
3330
var siteDefinitionRepo = Services.GetRequiredService<ISiteDefinitionRepository>();
34-
3531
siteDefinitionRepo.Save(new SiteDefinition()
3632
{
3733
Name = "TestSite",
3834
StartPage = startPage.ContentLink,
3935
SiteUrl = new Uri("http://localhost"),
4036
});
4137

38+
// Find first site
4239
var allSites = siteDefinitionRepo.List();
43-
4440
var site = allSites.First();
4541

42+
// Create NewsPage
4643
var news = repo.GetDefault<NewsPage>(site.StartPage);
4744
news.Name = "Alien Invasion";
4845
news.Title = "Martians Landed in Stockholm";
4946

50-
// Act
47+
// Act (Save and Load NewsPage)
5148
var savedRef = repo.Save(news, SaveAction.Publish, AccessLevel.NoAccess);
5249
var loaded = repo.Get<NewsPage>(savedRef);
5350

test/OptimizelyTestContainers.Tests/OptimizelyIntegrationTestBase.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@ public async Task InitializeAsync()
3737
{
3838
webBuilder.ConfigureServices((context, services) =>
3939
{
40-
// Add CMS services
41-
services.AddCms();
42-
services.AddCmsHost();
43-
services.AddCmsFrameworkWeb();
44-
services.AddCmsCoreWeb();
45-
services.AddCmsTemplating();
46-
services.AddCmsUI();
47-
4840
// Override connection string to use container connection
4941
services.Configure<DataAccessOptions>(opt =>
5042
{

test/OptimizelyTestContainers.Tests/OptimizelyTestContainers.Tests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
<IsPackable>false</IsPackable>
88
</PropertyGroup>
99

10+
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
11+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
12+
</PropertyGroup>
13+
14+
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
15+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
16+
</PropertyGroup>
17+
1018
<ItemGroup>
1119
<PackageReference Include="coverlet.collector" Version="6.0.4">
1220
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

0 commit comments

Comments
 (0)