Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.9.8

### Fixed
* Fix bug in `ContentControlBeforeContentUpdate` code by verifying the correct event name [#454](https://github.com/NetOfficeFw/NetOffice/pull/454)


## v1.9.7

### Added
Expand Down
1 change: 1 addition & 0 deletions Source/NetOffice.Tests/NetOffice.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<ProjectReference Include="..\NetOffice\NetOffice.csproj" />
<ProjectReference Include="..\Outlook\OutlookApi.csproj" />
<ProjectReference Include="..\PowerPoint\PowerPointApi.csproj" />
<ProjectReference Include="..\Word\WordApi.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="NetOffice\Tools\data\NativeAddinResiliency.bin">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 Cisco Systems, Inc.
// Licensed under MIT-style license (see LICENSE.txt file).

using System;
using NetOffice.WordApi;
using NetOffice.WordApi.Events;
using NetOffice.Tests.Helpers;
using NUnit.Framework;

namespace NetOffice.Tests.WordApi.Events
{
[TestFixture]
public class DocumentEvents2_SinkHelperTests
{
/// <summary>
/// Regression test for #453 - Ensures ContentControlBeforeContentUpdate event uses correct event name
/// in both Validate() and EventBinding.RaiseCustomEvent() calls
/// </summary>
[Test]
public void ContentControlBeforeContentUpdate_EventRaised_CallsHandlerWithCorrectEventName()
{
// Arrange
var eventBinder = new TestableComObjectStub();
eventBinder.AddEventRecipient(nameof(DocumentEvents2_SinkHelper.ContentControlBeforeContentUpdate));
var connectionPoint = new ConnectionPointStub();

var events = new DocumentEvents2_SinkHelper(eventBinder, connectionPoint);
var parameter1 = new FakeComObject();
var content = new object();

// Act
events.ContentControlBeforeContentUpdate(parameter1, ref content);
var actualParametersPassToEvent = eventBinder.LastRaisedEventParameters;

// Assert
Assert.AreEqual("ContentControlBeforeContentUpdate", eventBinder.LastRaisedEventName,
"EventBinding.RaiseCustomEvent must be called with 'ContentControlBeforeContentUpdate' event name");

CollectionAssert.IsNotEmpty(actualParametersPassToEvent);
var actualParameter1 = actualParametersPassToEvent[0];
Assert.IsInstanceOf<ContentControl>(actualParameter1,
"Event ContentControlBeforeContentUpdate parameter must be of type ContentControl.");
}
}
}
9 changes: 9 additions & 0 deletions Source/NetOffice.Tests/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,15 @@
"NetOfficeFw.Core": "[1.9.3, )",
"NetOfficeFw.Office": "[1.9.3, )"
}
},
"NetOfficeFw.Word": {
"type": "Project",
"dependencies": {
"NetOfficeFw.Core": "[1.9.3, )",
"NetOfficeFw.Office": "[1.9.3, )",
"NetOfficeFw.VBIDE": "[1.9.3, )",
"stdole": "[7.0.3300, )"
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Word/Events/DocumentEvents2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void ContentControlBeforeStoreUpdate([In, MarshalAs(UnmanagedType.IDispat

public void ContentControlBeforeContentUpdate([In, MarshalAs(UnmanagedType.IDispatch)] object contentControl, [In] [Out] ref object content)
{
if (!Validate("ContentControlBeforeStoreUpdate"))
if (!Validate("ContentControlBeforeContentUpdate"))
{
Invoker.ReleaseParamsArray(contentControl, content);
return;
Expand Down
Loading