public void SetUp() { _shimsContext = ShimsContext.Create(); InitShims(); query.Clear(); functionsInvoked.Clear(); maxDatareaderCount = 1; currentDataReaderCount = 0; _testEntity = new APIEmail(); _privateObject = new PrivateObject(_testEntity); _privateType = new PrivateType(typeof(APIEmail)); }
private void QueueItemMessageXml_Called_OkReturned( string listName, string listId, int itemId, string webId, Guid oWebId, Guid expectedWebApplicationId) { // Arrange var data = GetXml(listName, listId, itemId, webId); var shimSpWeb = new ShimSPWeb { IDGet = () => oWebId, SiteGet = () => new ShimSPSite { IDGet = () => Guid.NewGuid() } }; ShimAPITeam.GetResourcePoolStringSPWeb = (xml, web) => { var table = new DataTable(); table.Columns.Add("user"); table.Columns.Add("SPID"); var row = table.NewRow(); row["user"] = "******"; row["SPID"] = SpId; table.Rows.Add(row); return(table); }; ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = action => { action(); }; ShimQueueItemMessage(); // Act var result = APIEmail.QueueItemMessageXml(data, shimSpWeb); // Assert Assert.AreEqual(expectedWebApplicationId, _spListItemCalledXml.ParentList.ParentWeb.Site.WebApplication.Id); Assert.AreEqual(_calledTemplateId, 17); Assert.AreEqual(_calledAdditionalParams["Building"], "64b"); Assert.IsTrue(new[] { SpId }.SequenceEqual(_calledNewUsers)); Assert.IsTrue(new[] { "vladislav", "vitaliy" }.SequenceEqual(_calledDelUsers)); Assert.IsTrue(_calledDoNotEmail); Assert.IsTrue(_calledUnmarkread); }
public void TestInitialize() { _spListItemCalledXml = null; _shims = ShimsContext.Create(); ShimAPIEmail.Constructor = apiEmail => { _apiEmailShim = new ShimAPIEmail(apiEmail); }; _apiEmail = new APIEmail(); _apiEmailPrivate = new PrivateObject(_apiEmail); ShimCoreFunctions.getConnectionStringGuid = _ => { return(null); }; ShimIQueueItemMessage(); }
public void ClearNotificationItem_Called_ObjectDisposed() { // Arrange var spListItem = CreateShimSpListItem(_webAppGuid1); SqlConnection createdConnection = null; ShimSqlConnection.ConstructorString = (connection, _) => { createdConnection = connection; }; ShimSPSecurity.RunWithElevatedPrivilegesSPSecurityCodeToRunElevated = action => { action(); }; SqlConnection openedConnection = null; ShimSqlConnection.AllInstances.Open = connection => { openedConnection = connection; }; SqlCommand executedCommand = null; string executedSpName = null; CommandType? executedCommandType = null; SqlConnection executedCommandConnection = null; SqlParameterCollection executedParams = null; ShimSqlCommand.AllInstances.ExecuteNonQuery = command => { executedCommandConnection = command.Connection; executedSpName = command.CommandText; executedCommandType = command.CommandType; executedParams = command.Parameters; executedCommand = command; return(0); }; SqlConnection disposedConnection = null; ShimSqlConnection.AllInstances.DisposeBoolean = (connection, disposing) => { disposedConnection = connection; }; SqlCommand disposedCommand = null; ShimSqlCommand.AllInstances.DisposeBoolean = (command, disposing) => { disposedCommand = command; }; // Act APIEmail.ClearNotificationItem(spListItem); // Assert Assert.AreSame(createdConnection, openedConnection); Assert.IsNotNull(executedCommand); Assert.AreEqual("spNDeleteNotification", executedSpName); Assert.AreEqual(CommandType.StoredProcedure, executedCommandType); Assert.AreEqual(2, executedParams.Count); Assert.AreEqual("@listid", executedParams[0].ParameterName); Assert.AreEqual("@itemid", executedParams[1].ParameterName); Assert.AreSame(executedCommand, disposedCommand); }