or
public
class
JustMockFixture
{
[Fact]
public
void
CallOriginal_UnmockedGenericMethod_CallOriginalMock_ThrowsException()
{
var obj = Mock.Create<TestClass>(Behavior.CallOriginal);
Should.NotThrow(() => obj.Load<
string
>(
new
[] {
"1"
,
"2"
,
"3"
}));
}
}
internal
class
TestClass
{
public
T[] Load<T>(
string
[] ids)
{
throw
new
NotImplementedException();
}
}
public
class
FooFactory
{
public
static
IFoo CreateFoo(
int
barKey)
{
using
(FooBarModel foom =
new
FooBarModel())
{
Bar barEntity = foom.Bars.Where(n => n.BarKey == barKey).FirstOrDefault();
// For this example, I will assume the bar record always exists.
if
(barEntity.IsIron)
{
return
new
IronFoo();
}
else
if
(barEntity.IsGold)
{
return
new
GoldenFoo();
}
else
{
return
new
LeadFoo();
}
}
}
}
System.InvalidCastException:
'System.Collections.Generic.List`1[My.Models.Person]' to type 'System.Data.Linq.Table`1[My.Models.Person]'
var logic =
new
PersonLogic();
var context = Mock.Create<DataContext>();
var persons=
new
List<Person>();
persons.Add(
new
Person());
Mock.Arrange(() => (IEnumerable<Person>)context.Persons).Returns(persons);
Mock.NonPublic.Arrange<DataContext>(logic,
"context"
).Returns(context);
Person returned = logic.GetPerson(1);
Assert.Equals(returned.ID, 1);
Test method Win8Proto.Tests.WhenUserIsNotAuthenticated.ThenTryParseOAuthCallbackUrlIsCalled threw exception: <
br
>System.Resources.MissingManifestResourceException:
Unable to load resources for resource file "Telerik.JustMock.Messages" in package "97A458C7-A0AA-4BC7-B8FA-D9F82394A7BE".<
br
>
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)<
br
> at Telerik.JustMock.Messages.get_ExpectedCallIsNeverInvoked()<
br
>
at Telerik.JustMock.MockAssertion.AssertValidator.ValidateExpectations(MethodInstance methodInstance, Int32 numberofTimeExecuted)<
br
>
at Telerik.JustMock.MockAssertion.AssertValidator.ToExceptionString(MethodInstance methodInstance)<
br
>
at Telerik.JustMock.MockAssertion.AssertValidator.Validate()<
br
> at Telerik.JustMock.MockAssertion.Assert(MethodInstance instance, Filter filter)<
br
>
at Telerik.JustMock.Mock.AssertInternal(Occurs occurs)<
br
> at Telerik.JustMock.Helpers.FluentHelper.<>c__DisplayClass7`2.<
Assert
>b__6(MockContext`1 x)<
br
>
at Telerik.JustMock.MockContext.Setup(Instruction instruction, Action`1 action)<
br
> at Telerik.JustMock.Helpers.FluentHelper.Assert(T obj, Expression`1 expression, Occurs occurs)<
br
>
at Telerik.JustMock.Helpers.FluentHelper.Assert(T obj, Expression`1 action)<
br
> at Win8Proto.Tests.WhenUserIsNotAuthenticated.ThenTryParseOAuthCallbackUrlIsCalled() in WithMockFacebookClient.cs: line 104<
br
>
<
div
></
div
>
Mock.Replace<System.Drawing.Printing.PrintDocument>(p => p.Print()).In<PrintJobTest>(t => t.Ensure_Print_Job_Folder_Name());
var printDocument =
new
System.Drawing.Printing.PrintDocument();
Mock.Arrange(() => printDocument.Print()).IgnoreInstance().DoNothing();
private
PendingListViewModel _vm;
[TestInitialize]
public
void
Setup()
{
var view = Mock.Create<IPendingListView>();
var repository = Mock.Create<ISubmissionRepository>();
repository.Arrange(x => x.GetPendingSubmissions()).Returns(GetSubmissionSet());
var subscribedEvent = Mock.Create<RefreshPendingSubmissions>();
subscribedEvent.Arrange(x => x.Subscribe(Arg.IsAny<Action<
string
>>())).DoNothing();
var events = Mock.Create<IEventAggregator>();
events.Arrange(x => x.GetEvent<RefreshPendingSubmissions>()).Returns(subscribedEvent);
_vm =
new
PendingListViewModel(view, repository, events);
}
[TestMethod]
public
void
ExecuteSortByCountyCommand_CollectionShouldContainOneSortDescriptor()
{
_vm.SortCountyCommand.Execute(
"ASC"
);
Assert.IsTrue(_vm.SubmissionsCollection.SortDescriptions.Count == 1);
}
_events.GetEvent<RefreshPendingSubmissions>().Subscribe(a => OnRefresh());
public enum SubdivisionTypeCode : byte
{
None = 255,
State = 0,
County = 1,
City = 2,
Village = 3,
Township = 4,
CitySchoolDistrict = 5,
SchoolDistrict = 6,
JtVocSchoolDistrict = 7,
Miscellaneous = 8,
University = 9,
PooledFinancing = 10
}
public interface ISubdivisionTypeRepository
{
ISubdivisionType Get(SubdivisionTypeCode subdivisionTypeCode);
}
...
[Test]
var subdivisionTypeCode = SubdivisionTypeCode.City;
var subdivisionType = new SubdivisionType(subdivisionTypeCode: SubdivisionTypeCode.City);
var subdivisionTypeRepository = Mock.Create<
ISubdivisionTypeRepository
>();
Mock.Arrange(() => subdivisionTypeRepository.Get(subdivisionTypeCode)).Returns(subdivisionType);
var s = subdivisionTypeRepository.Get(subdivisionTypeCode);