Skip to content

Commit

Permalink
Fixe issues and tests failing after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ivarne committed Oct 3, 2024
1 parent cc73fd4 commit 3fb19e0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ReadOnlyMemory<byte> SerializeToXml(object model)
NewLineHandling = NewLineHandling.None,
};
using var memoryStream = new MemoryStream();
XmlWriter xmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings);
using XmlWriter xmlWriter = XmlWriter.Create(memoryStream, xmlWriterSettings);

XmlSerializer serializer = _xmlSerializer.GetSerializer(modelType);
serializer.Serialize(xmlWriter, model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Type type
var (data, contentType) = _modelSerializationService.SerializeToStorage(dataToSerialize, dataType);

StreamContent streamContent = new StreamContent(new MemoryAsStream(data));
streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/xml");
streamContent.Headers.ContentType = MediaTypeHeaderValue.Parse(contentType);
HttpResponseMessage response = await _client.PostAsync(token, apiUrl, streamContent);

if (response.IsSuccessStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public List<DataElementChange> GetDataElementChanges(bool initializeAltinnRowId)
{
ObjectUtils.InitializeAltinnRowId(data);
}
var (currentBinary, contentType) = _modelSerializationService.SerializeToStorage(data, dataType);
var (currentBinary, _) = _modelSerializationService.SerializeToStorage(data, dataType);
_binaryCache.Set(dataElementIdentifier, currentBinary);

if (!currentBinary.Span.SequenceEqual(previousBinary.Span))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ public async Task RunProcessNext_DataFromHiddenComponents_GetsRemoved()
// Mock pdf generation so that the test does not fail due to pof service not running.
var pdfMock = new Mock<IPdfGeneratorClient>(MockBehavior.Strict);
using var pdfReturnStream = new MemoryStream();
pdfMock.Setup(p => p.GeneratePdf(It.IsAny<Uri>(), It.IsAny<CancellationToken>())).ReturnsAsync(pdfReturnStream);
pdfMock
.Setup(p => p.GeneratePdf(It.IsAny<Uri>(), It.IsAny<string?>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(pdfReturnStream);
OverrideServicesForThisTest = (services) =>
{
services.AddSingleton(pdfMock.Object);
Expand Down Expand Up @@ -385,7 +387,9 @@ public async Task RunProcessNext_ShadowFields_GetsRemoved(string? saveToDataType
// Mock pdf generation so that the test does not fail due to pof service not running.
var pdfMock = new Mock<IPdfGeneratorClient>(MockBehavior.Strict);
using var pdfReturnStream = new MemoryStream();
pdfMock.Setup(p => p.GeneratePdf(It.IsAny<Uri>(), It.IsAny<CancellationToken>())).ReturnsAsync(pdfReturnStream);
pdfMock
.Setup(p => p.GeneratePdf(It.IsAny<Uri>(), It.IsAny<string?>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(pdfReturnStream);
OverrideServicesForThisTest = (services) =>
{
services.AddSingleton(pdfMock.Object);
Expand Down
2 changes: 1 addition & 1 deletion test/Altinn.App.Api.Tests/Mocks/DataClientMock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ string dataTypeString
Id = dataGuid.ToString(),
InstanceGuid = instanceGuid.ToString(),
DataType = dataTypeString,
ContentType = "application/xml",
ContentType = contentType,
};

Directory.CreateDirectory(dataPath + @"blob");
Expand Down
2 changes: 1 addition & 1 deletion test/Altinn.App.Core.Tests/Helpers/MemoryAsStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Altinn.App.Core.Tests.Helpers;

public class MemoryAsStreamTests
{
private static byte[] _byteSequence = GenerateNonRepeatingByteArray();
private static readonly byte[] _byteSequence = GenerateNonRepeatingByteArray();

/// <summary>
/// For testing <see cref="MemoryAsStream"/> class we need to handle a sequence of bytes where errors are
Expand Down

0 comments on commit 3fb19e0

Please sign in to comment.