mirror of
https://github.com/opengram-server/opengram.git
synced 2026-07-24 06:26:11 +03:00
Initial commit
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
|
||||
<ConfigureAwait />
|
||||
</Weavers>
|
||||
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
|
||||
<xs:element name="Weavers">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
|
||||
<xs:annotation>
|
||||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
<xs:attribute name="GenerateXsd" type="xs:boolean">
|
||||
<xs:annotation>
|
||||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
|
||||
</xs:annotation>
|
||||
</xs:attribute>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,13 @@
|
||||
global using System;
|
||||
global using System.IO;
|
||||
global using System.Linq;
|
||||
global using System.Collections;
|
||||
global using System.Collections.Generic;
|
||||
global using System.Buffers;
|
||||
|
||||
global using Xunit;
|
||||
global using Shouldly;
|
||||
|
||||
global using MyTelegram.Schema.Extensions;
|
||||
global using MyTelegram.Schema.Serializer;
|
||||
global using MyTelegram.TestBase;
|
||||
@@ -0,0 +1,39 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="coverlet.collector">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Shouldly" />
|
||||
<PackageReference Include="xunit" />
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\MyTelegram.Services\MyTelegram.Services.csproj" />
|
||||
<ProjectReference Include="..\..\src\MyTelegram.TestBase\MyTelegram.TestBase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Update="Fody">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,104 @@
|
||||
using Moq;
|
||||
using MyTelegram.Services.TLObjectConverters;
|
||||
|
||||
namespace MyTelegram.Services.Tests.TLObjectConverters;
|
||||
|
||||
public class LayeredServiceTests : TestsFor<LayeredService<ILayeredConverter>>
|
||||
{
|
||||
private List<ILayeredConverter> _converters = [];
|
||||
|
||||
private void SetupConverters(List<int> layers)
|
||||
{
|
||||
_converters =
|
||||
[
|
||||
.. layers.Select(layer =>
|
||||
{
|
||||
var mockConverter = new Mock<ILayeredConverter>();
|
||||
mockConverter.SetupGet(c => c.Layer).Returns(layer);
|
||||
return mockConverter.Object;
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
protected override LayeredService<ILayeredConverter> CreateSut()
|
||||
{
|
||||
return new LayeredService<ILayeredConverter>(_converters);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(new int[] { 180, 184, 195, 198 }, 0, 198)]
|
||||
[InlineData(new int[] { 180, 184, 195, 198 }, 184, 184)]
|
||||
[InlineData(new int[] { 180, 184, 195, 198 }, 100, 180)]
|
||||
[InlineData(new int[] { 180, 184, 195, 198 }, 250, 198)]
|
||||
[InlineData(new int[] { 180, 184, 195, 198 }, 190, 195)]
|
||||
[InlineData(new int[] { 180, 191, 195, 198 }, 187, 191)]
|
||||
[InlineData(new int[] { 184, 195, 198 }, 187, 195)]
|
||||
|
||||
public void GetConverter_ShouldReturnExpectedLayer(int[] layers, int requestLayer, int expectedLayer)
|
||||
{
|
||||
SetupConverters([.. layers]);
|
||||
var sut = CreateSut();
|
||||
|
||||
var result = sut.GetConverter(requestLayer);
|
||||
|
||||
result.Layer.ShouldBe(expectedLayer);
|
||||
}
|
||||
|
||||
//public LayeredServiceTests()
|
||||
//{
|
||||
// var mockConverter1 = new Mock<ILayeredConverter>();
|
||||
// var mockConverter2 = new Mock<ILayeredConverter>();
|
||||
// var mockConverter3 = new Mock<ILayeredConverter>();
|
||||
// var mockConverter4 = new Mock<ILayeredConverter>();
|
||||
|
||||
// mockConverter1.SetupGet(c => c.Layer).Returns(180);
|
||||
// mockConverter2.SetupGet(c => c.Layer).Returns(184);
|
||||
// mockConverter3.SetupGet(c => c.Layer).Returns(195);
|
||||
// mockConverter4.SetupGet(c => c.Layer).Returns(198);
|
||||
|
||||
// Inject<IEnumerable<ILayeredConverter>>(new List<ILayeredConverter>([mockConverter1.Object, mockConverter2.Object, mockConverter3.Object,
|
||||
// mockConverter4.Object]));
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public void Constructor_ShouldInitializeCorrectly()
|
||||
//{
|
||||
// Sut.Converter.Layer.ShouldBe(198);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public void GetConverter_ShouldReturnLatestLayerConverter_WhenLayerIsZero()
|
||||
//{
|
||||
// var result = Sut.GetConverter(0);
|
||||
// result.Layer.ShouldBe(198);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public void GetConverter_ShouldReturnExactMatch_WhenLayerExists()
|
||||
//{
|
||||
// var result = Sut.GetConverter(184);
|
||||
// result.Layer.ShouldBe(184);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public void GetConverter_ShouldReturnMinLayerConverter_WhenLayerBelowMin()
|
||||
//{
|
||||
// var result = Sut.GetConverter(100);
|
||||
// result.Layer.ShouldBe(180);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//[Theory]
|
||||
//public void GetConverter_ShouldReturnMaxLayerConverter_WhenLayerAboveMax()
|
||||
//{
|
||||
// var result = Sut.GetConverter(250);
|
||||
// result.Layer.ShouldBe(198);
|
||||
//}
|
||||
|
||||
//[Fact]
|
||||
//public void GetConverter_ShouldReturnClosestLowerLayer_WhenLayerNotExists()
|
||||
//{
|
||||
// var result = Sut.GetConverter(190);
|
||||
// result.Layer.ShouldBe(184);
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//namespace MyTelegram.Services.Tests;
|
||||
|
||||
//public class UnitTest1
|
||||
//{
|
||||
// [Fact]
|
||||
// public void Test1()
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user