Skip to content

Instantly share code, notes, and snippets.

@Vaccano
Created February 19, 2010 23:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vaccano/309339 to your computer and use it in GitHub Desktop.
Save Vaccano/309339 to your computer and use it in GitHub Desktop.
/ <copyright file="WorkWithRandomsTest.CreateSomeRandoms.g.cs" company="ARUP Laboratories">Copyright © ARUP Laboratories 2010</copyright>
// <auto-generated>
// This file contains automatically generated unit tests.
// Do NOT modify this file manually.
//
// When Pex is invoked again,
// it might remove or update any previously generated unit tests.
//
// If the contents of this file becomes outdated, e.g. if it does not
// compile anymore, you may delete this file and invoke Pex again.
// </auto-generated>
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Pex.Framework.Generated;
using System.Collections.Generic;
namespace PexTestExample
{
public partial class WorkWithRandomsTest
{
[TestMethod]
[PexGeneratedBy(typeof(WorkWithRandomsTest))]
[PexRaisedException(typeof(NullReferenceException))]
public void CreateSomeRandomsThrowsNullReferenceExceptionx841()
{
RandomClass randomClass;
randomClass = this.CreateSomeRandoms((RandomContract)null);
}
[TestMethod]
[PexGeneratedBy(typeof(WorkWithRandomsTest))]
[ExpectedException(typeof(ArgumentNullException))]
public void CreateSomeRandomsThrowsArgumentNullExceptionx474()
{
RandomClass randomClass;
RandomContract s0 = new RandomContract();
s0.SubRandomContracts = (List<SubRandomContract>)null;
s0.ContractName = (string)null;
randomClass = this.CreateSomeRandoms(s0);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PexTestExample
{
public class RandomClass
{
public RandomClass()
{
SubRandoms = new List<SubRandomClass>();
}
public List<SubRandomClass> SubRandoms { get; set; }
public String Name { get; set; }
}
public class SubRandomClass
{
public String SubName { get; set; }
}
public static class WorkWithRandoms
{
public static RandomClass CreateSomeRandoms(RandomContract randomContract)
{
RandomClass newRandom = new RandomClass
{
Name = randomContract.ContractName,
SubRandoms = FillSubContracts(randomContract.SubRandomContracts)
};
return newRandom;
}
public static List<SubRandomClass> FillSubContracts(List<SubRandomContract> contracts)
{
if (contracts == null)
throw new ArgumentNullException("contracts");
var result = new List<SubRandomClass>();
contracts.ForEach(x=> result.Add(new SubRandomClass{SubName = x.ContractSubName}));
return result;
}
}
public class RandomContract
{
public List<SubRandomContract> SubRandomContracts { get; set; }
public String ContractName { get; set; }
}
public class SubRandomContract
{
public String ContractSubName { get; set; }
}
}
using System;
using Microsoft.Pex.Framework;
using Microsoft.Pex.Framework.Validation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PexTestExample;
namespace PexTestExample
{
/// <summary>This class contains parameterized unit tests for WorkWithRandoms</summary>
[PexClass(typeof(WorkWithRandoms))]
[PexAllowedExceptionFromTypeUnderTest(typeof(InvalidOperationException))]
[PexAllowedExceptionFromTypeUnderTest(typeof(ArgumentException), AcceptExceptionSubtypes = true)]
[TestClass]
public partial class WorkWithRandomsTest
{
/// <summary>Test stub for CreateSomeRandoms(RandomContract)</summary>
[PexMethod]
public RandomClass CreateSomeRandoms(RandomContract randomContract)
{
RandomClass result = WorkWithRandoms.CreateSomeRandoms(randomContract);
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment