Skip to content

Commit

Permalink
Extend interfaces to support FileStorage DynamicsValue/fake-xrm-easy#157
Browse files Browse the repository at this point in the history
  • Loading branch information
jordimontana82 committed Aug 20, 2024
1 parent 532b3ba commit f32044c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [2.6.0]

### Added
-
- Add new method to Initialize Files to support InMemory File Db - https://github.com/DynamicsValue/fake-xrm-easy/issues/157

## [2.5.0]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<TargetFrameworks Condition="'$(Configuration)'=='FAKE_XRM_EASY_2013'">net452</TargetFrameworks>
<TargetFrameworks Condition="'$(Configuration)'=='FAKE_XRM_EASY'">net452</TargetFrameworks>
<PackageId>FakeXrmEasy.Abstractions</PackageId>
<VersionPrefix>2.5.0</VersionPrefix>
<VersionPrefix>2.6.0</VersionPrefix>
<Authors>Jordi Montaña</Authors>
<Company>Dynamics Value</Company>
<Title>FakeXrmEasy Abstractions</Title>
Expand Down
40 changes: 40 additions & 0 deletions src/FakeXrmEasy.Abstractions/FileStorage/IFIleAttachment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.Xrm.Sdk;

namespace FakeXrmEasy.Abstractions.FileStorage
{
/// <summary>
/// Represents a file associated to an existing Dataverse record.
/// </summary>
public interface IFileAttachment
{
/// <summary>
/// The unique identifier of the file to be uploaded(i.e. the Guid of the fileattachment record)
/// </summary>
string Id { get; set; }

/// <summary>
/// The file name, including the file extension
/// </summary>
string FileName { get; set; }

/// <summary>
/// The file MIME type
/// </summary>
string MimeType { get; set; }

/// <summary>
/// The actual file contents as a byte array
/// </summary>
byte[] Content { get; set; }

/// <summary>
/// The associated record to which this file belongs
/// </summary>
EntityReference Target { get; set; }

/// <summary>
/// The logical name of the File or Image column / field of the Target EntityReference
/// </summary>
string AttributeName { get; set; }
}
}
7 changes: 7 additions & 0 deletions src/FakeXrmEasy.Abstractions/IXrmFakedContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using FakeXrmEasy.Abstractions.FileStorage;

namespace FakeXrmEasy.Abstractions
{
Expand Down Expand Up @@ -206,5 +207,11 @@ public interface IXrmFakedContext: IXrmBaseContext
/// <param name="logicalName">The entity logical name of the entity</param>
/// <returns>An early-bound record dif the context is already using early-bound entity records, a late bound entity otherwise</returns>
Entity NewEntityRecord(string logicalName);

/// <summary>
/// Initializes the context with a given state of pre-existing file uploads
/// </summary>
/// <param name="files">The list of files used to initialised the In-Memory File Storage. InitializeMetadata and Initialize must have been called prior to calling this method.</param>
void InitializeFiles(IEnumerable<IFileAttachment> files);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<IsPackable>true</IsPackable>

<PackageId>FakeXrmEasy.AbstractionsTests</PackageId>
<VersionPrefix>2.5.0</VersionPrefix>
<VersionPrefix>2.6.0</VersionPrefix>
<Authors>Jordi Montaña</Authors>
<Company>Dynamics Value S.L.</Company>
<Title>FakeXrmEasy Abstractions Tests</Title>
Expand All @@ -28,6 +28,7 @@
<ItemGroup>
<None Include="../../LICENSE.txt" Pack="true" PackagePath="$(PackageLicenseFile)" />
<None Include="../../FakeXrmEasyLogo_128x128.png" Pack="true" PackagePath="/" />
<None Remove="Plugins\**" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462' And '$(Configuration)'=='FAKE_XRM_EASY_9'">
Expand Down Expand Up @@ -71,25 +72,28 @@
</ItemGroup>

<ItemGroup Condition="'$(PackTests)' == 'true' And '$(Configuration)'=='FAKE_XRM_EASY'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2011" Version="2.5.0-*" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2011" Version="[2.6.0-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(PackTests)' == 'true' And '$(Configuration)'=='FAKE_XRM_EASY_2013'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2013" Version="2.5.0-*" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2013" Version="[2.6.0-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(PackTests)' == 'true' And '$(Configuration)'=='FAKE_XRM_EASY_2015'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2015" Version="2.5.0-*" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2015" Version="[2.6.0-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(PackTests)' == 'true' And '$(Configuration)'=='FAKE_XRM_EASY_2016'">
<PackageReference Include="FakeXrmEasy.Abstractions.v2016" Version="2.5.0-*" />
<PackageReference Include="FakeXrmEasy.Abstractions.v2016" Version="[2.6.0-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(PackTests)' == 'true' And '$(Configuration)'=='FAKE_XRM_EASY_365'">
<PackageReference Include="FakeXrmEasy.Abstractions.v365" Version="2.5.0-*" />
<PackageReference Include="FakeXrmEasy.Abstractions.v365" Version="[2.6.0-*,3.0)" />
</ItemGroup>
<ItemGroup Condition="'$(PackTests)' == 'true' And '$(Configuration)'=='FAKE_XRM_EASY_9'">
<PackageReference Include="FakeXrmEasy.Abstractions.v9" Version="2.5.0-*" />
<PackageReference Include="FakeXrmEasy.Abstractions.v9" Version="[2.6.0-*,3.0)" />
</ItemGroup>
<ItemGroup>
<Folder Include="Plugins\" />
<Compile Remove="Plugins\**" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="Plugins\**" />
</ItemGroup>

</Project>

0 comments on commit f32044c

Please sign in to comment.