public void ToString_Always_ReturnsPreviewDescription() { const string ProjectName = "ProjectA"; var added = new List <AccessiblePackageIdentity>(); var deleted = new List <AccessiblePackageIdentity>(); var updated = new List <UpdatePreviewResult>(); added.Add(new AccessiblePackageIdentity(new PackageIdentity("PkgA", new Versioning.NuGetVersion("1.2.3")))); deleted.Add(new AccessiblePackageIdentity(new PackageIdentity("PkgB", new Versioning.NuGetVersion("3.2.1")))); updated.Add(new UpdatePreviewResult( new PackageIdentity("PkgC", new Versioning.NuGetVersion("1.0.0")), new PackageIdentity("PkgC", new Versioning.NuGetVersion("2.0.0")))); var previewResult = new PreviewResult(ProjectName, added, deleted, updated); var allResults = new List <PreviewResult>(); allResults.Add(previewResult); var model = new PreviewWindowModel(allResults); var sb = new StringBuilder(); sb.AppendLine(ProjectName); sb.AppendLine(); sb.AppendLine(Resources.Label_UninstalledPackages); sb.AppendLine(); foreach (AccessiblePackageIdentity packageIdentity in deleted) { sb.AppendLine(packageIdentity.ToString()); } sb.AppendLine(); sb.AppendLine(Resources.Label_UpdatedPackages); sb.AppendLine(); foreach (UpdatePreviewResult result in updated) { sb.AppendLine(result.ToString()); } sb.AppendLine(); sb.AppendLine(Resources.Label_InstalledPackages); sb.AppendLine(); foreach (AccessiblePackageIdentity packageIdentity in added) { sb.AppendLine(packageIdentity.ToString()); } sb.AppendLine(); Assert.Equal(sb.ToString(), model.ToString()); }
public void PreviewWindowModelToString_Test() { var added = new List <AccessiblePackageIdentity>(); var deleted = new List <AccessiblePackageIdentity>(); var updated = new List <UpdatePreviewResult>(); added.Add(new AccessiblePackageIdentity(new PackageIdentity("PkgA", new Versioning.NuGetVersion("1.2.3")))); deleted.Add(new AccessiblePackageIdentity(new PackageIdentity("PkgB", new Versioning.NuGetVersion("3.2.1")))); updated.Add(new UpdatePreviewResult( new PackageIdentity("PkgC", new Versioning.NuGetVersion("1.0.0")), new PackageIdentity("PkgC", new Versioning.NuGetVersion("2.0.0")) )); var ProjA = new MockProject(); var previewResult = new PreviewResult(ProjA, added, deleted, updated); var allResults = new List <PreviewResult>(); allResults.Add(previewResult); var model = new PreviewWindowModel(allResults); var sb = new StringBuilder(); sb.AppendLine(Resources.Preview_UnknownProject); sb.AppendLine(); sb.AppendLine(Resources.Label_UninstalledPackages); sb.AppendLine(); foreach (var p in deleted) { sb.AppendLine(p.ToString()); } sb.AppendLine(); sb.AppendLine(Resources.Label_UpdatedPackages); sb.AppendLine(); foreach (var p in updated) { sb.AppendLine(p.ToString()); } sb.AppendLine(); sb.AppendLine(Resources.Label_InstalledPackages); sb.AppendLine(); foreach (var p in added) { sb.AppendLine(p.ToString()); } sb.AppendLine(); Assert.Equal(sb.ToString(), model.ToString()); }