using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using FakeXrmEasy;
using System.Reflection;
using Microsoft.Xrm.Sdk;
using System.Collections.Generic;
using CrmEarlyBound;
using System.Linq;
namespace ExecuteMultipleUnitTest {
[TestClass]
public class UnitTest1 {
[TestMethod]
public void TestMethod1_Passed() {
var context = new XrmFakedContext();
context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));
var account = new Account {
Id = Guid.NewGuid(),
Name = "An Account"
};
context.Initialize(new List < Account > () {
account
});
var service = context.GetFakedOrganizationService();
var accountToUpdate = new Account() {
Id = account.Id
};
accountToUpdate.Name = "A new faked name!";
service.Update(accountToUpdate);
var updatedAccountName = context.CreateQuery < Account > ()
.Where(e => e.Id == account.Id)
.FirstOrDefault();
Assert.AreEqual("A new faked name!", updatedAccountName.Name);
}
[TestMethod]
public void TestMethod1_Failed() {
var context = new XrmFakedContext();
context.ProxyTypesAssembly = Assembly.GetAssembly(typeof(Account));
var account = new Account {
Id = Guid.NewGuid(),
Name = "An Account"
};
context.Initialize(new List < Account > () {
account
});
var service = context.GetFakedOrganizationService();
var accountToUpdate = new Account() {
Id = account.Id
};
accountToUpdate.Name = "A new faked name1!";
service.Update(accountToUpdate);
var updatedAccountName = context.CreateQuery < Account > ()
.Where(e => e.Id == account.Id)
.FirstOrDefault();
Assert.AreEqual("A new faked name!", updatedAccountName.Name);
}
}
}