网站首页 网站源码
website
站点相关全部源代码,隐藏了一些关于服务器的信息
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using AutoMapper;
using Dpz.Core.Infrastructure;
using Dpz.Core.MongodbAccess;
using Dpz.Core.Public.Entity.Option;
using Dpz.Core.Public.ViewModel.Option;
using Dpz.Core.Service;
using Dpz.Core.Service.RepositoryServiceImpl;
using EasyCaching.Core;
using EasyCaching.Core.Configurations;
using EasyCaching.Core.DistributedLock;
using EasyCaching.InMemory;
using EasyCaching.Redis;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;

namespace Dpz.Core.ServiceTest;

[TestFixture]
public class AppOptionServiceTest : Basic
{

    [Test]
    public async Task AddFriendTest()
    {
        var service = new AppOptionService(AppOptionRepository, HybridCachingProvider,Mapper);

        var friend = new VmFriends()
        {
            Avatar = "https://localhost:37701/Home/Image/61f28989337b51b42fc24686",
            Description =
                "汤加洪阿哈阿帕伊火山喷发迄今已经过去了10多天。除了风云系列气象卫星,我国的多颗高分、海洋系列卫星也在持续获取遥感影像,可以看出汤加火山喷发带来的变化。洪阿哈阿帕伊岛位于汤加首都努库阿洛法以北约65公里处,火山喷发前由两个小岛与火山岩组成,而到了1月16日,原来连在一起的火山岛变成了两个小岛,中间的火山岩直接消失了,变成了水域。",
            Link = "https://localhost:37701/article/read/61f2898c337b51b42fc24696.html",
            Name = "中国卫星集体跟拍汤加火山现状"
        };
        await service.AddFriendAsync(friend);
    }

    [Test]
    public async Task GetFriendsTest()
    {
        var service = new AppOptionService(AppOptionRepository, HybridCachingProvider,Mapper);
        var list = await service.GetFriendsAsync();

        Assert.NotNull(list);

        Assert.Greater(list.Count, 0);

        list.ForEach(x => Console.WriteLine(JsonSerializer.Serialize(x)));
    }

    [Test]
    [TestCase("61f24eb63e68328408c1648c")]
    public async Task FindTest(string id)
    {
        var service = new AppOptionService(AppOptionRepository, HybridCachingProvider,Mapper);
        var model = await service.FindAsync(id);

        Assert.NotNull(model);

        Console.WriteLine(model);
    }

    [Test]
    [TestCase("61f25a09a87ec22504cd2906")]
    public async Task EditFriendsTest(string id)
    {
        var service = new AppOptionService(AppOptionRepository, HybridCachingProvider,Mapper);
        var model = await service.FindAsync(id);

        Assert.NotNull(model);

        if (model is VmFriends friend)
        {
            const string name = "Blazor WebAssembly站点   3";
            friend.Name = name;
            await service.EditFriendAsync(friend);

            var newModel = await service.FindAsync(id);

            Assert.NotNull(newModel);

            var newFriend = newModel as VmFriends;

            Assert.NotNull(newFriend);

            Assert.AreEqual(name, newFriend.Name);
        }
    }

    [Test]
    [TestCase("pengqian")]
    public async Task GetSaltTest(string account)
    {
        var service = new AppOptionService(AppOptionRepository, HybridCachingProvider,Mapper);
        var salt = await service.GetSaltAsync(account);

        Assert.NotNull(salt);

        Assert.AreEqual(account, salt.Account);

        Console.WriteLine(JsonSerializer.Serialize(salt));
    }

    [Test]
    [TestCase("footer123123")]
    public async Task SaveFooterTest(string content)
    {
        var service = new AppOptionService(AppOptionRepository, HybridCachingProvider,Mapper);
        await service.SaveFooterContentAsync(content);

        var dbContent = await service.GetFooterContentAsync();

        Assert.IsTrue(content == dbContent);
    }
}
loading