C#UnitTest on the GPT Store
GPT Description
GPT Prompt Starters
- 使用NUnit框架为以下代码生成单元测试 ``` csharp /// <summary> /// Class RunHelper. /// SourceLink:https://github.com/FoundatioFx/Foundatio/blob/master/src/Foundatio/Utility/Run.cs /// </summary> public static class RunHelper { /// <summary> /// Withes the retries. /// </summary> /// <param name="action">The action.</param> /// <param name="maxAttempts">The maximum attempts.</param> /// <param name="retryInterval">The retry interval.</param> public static void WithRetries(Action action, int maxAttempts = 5, TimeSpan? retryInterval = null) { WithRetries<object>(() => { action(); return null; }, maxAttempts, retryInterval); } /// <summary> /// Withes the retries. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="action">The action.</param> /// <param name="maxAttempts">The maximum attempts.</param> /// <param name="retryInterval">The retry interval.</param> /// <returns>T.</returns> /// <exception cref="System.ArgumentNullException">action</exception> /// <exception cref="Kmmp.Core.Models.KmHttpError.Exception">不应该到这里</exception> public static T WithRetries<T>(Func<T> action, int maxAttempts = 5, TimeSpan? retryInterval = null) { if (action == null) { throw new ArgumentNullException(nameof(action)); } int attempts = 1; var startTime = System.DateTime.Now; int currentBackoffTime = _defaultBackoffIntervals[0]; if (retryInterval != null) { currentBackoffTime = (int)retryInterval.Value.TotalMilliseconds; } do { if (attempts > 1) { SysLogHelper.Info("WithRetries", "Retrying {0} attempt after {1:g}...".Fmt(attempts.ToOrdinal(), DateTime.Now.Subtract(startTime))); } try { return action(); } catch (Exception ex) { if (attempts >= maxAttempts) { throw; } string strAddition = $"Retry error,action:{action.Method.Name}"; SysLogHelper.Error(ex, strAddition: strAddition); SleepSafe(currentBackoffTime); } if (retryInterval == null) { currentBackoffTime = _defaultBackoffIntervals[Math.Min(attempts, _defaultBackoffIntervals.Length - 1)]; } attempts++; } while (attempts <= maxAttempts); throw new Exception("不应该到这里"); } /// <summary> /// The default backoff intervals /// </summary> private static readonly int[] _defaultBackoffIntervals = new int[] { 100, 1000, 2000, 2000, 5000, 5000, 10000, 30000, 60000 }; /// <summary> /// Sleeps the safe. /// </summary> /// <param name="milliseconds">The milliseconds.</param> public static void SleepSafe(int milliseconds) { try { Thread.Sleep(milliseconds); } catch (OperationCanceledException) { } catch (Exception) { } } } ```
- 使用XUnit框架为C#冒泡排序算法生成单元测试
- 使用MSTest框架为C#快速排序算法生成单元测试
- 仔细阅读以下代码,使用NUnit框架为以下代码生成全面的单元测试, 并处理各种输入场景,包括嵌套字典和列表。 ```csharp /// <summary> /// 构建 HTTP 查询字符串。 /// </summary> /// <param name="data">包含查询参数的字典。</param> /// <param name="prefix">前缀。</param> /// <param name="isSub">指示是否为子对象。</param> /// <returns>构建的查询字符串。</returns> public static string HttpBuildQuery(Dictionary<string, object> data, string prefix = "", bool isSub = false) { var queryParams = new List<string>(); var sortedData = new SortedDictionary<string, object>(data); foreach (var kvp in sortedData) { // 跳过签名字段 if (kvp.Key == "sign") continue; string key = kvp.Key; object value = kvp.Value; // 构建键的完整路径 if (isSub) { key = prefix + (int.TryParse(key, out _) ? "[]" : $"[{key}]"); } else if (int.TryParse(key, out _)) { key = prefix + key; } if (value is Dictionary<string, object> dictValue) { if (dictValue.Count == 0) { queryParams.Add($"{key}=[]"); } else { queryParams.Add(HttpBuildQuery(dictValue, key, true)); } } else if (value is IList listValue) { var subList = new Dictionary<string, object>(); for (int i = 0; i < listValue.Count; i++) { subList.Add(i.ToString(), listValue[i]); } queryParams.Add(HttpBuildQuery(subList, key, true)); } else { queryParams.Add($"{key}={UrlEncode(value)}"); } } return string.Join("&", queryParams); } /// <summary> /// 对对象进行 URL 编码。 /// </summary> /// <param name="value">要编码的对象。</param> /// <returns>URL 编码后的字符串。</returns> private static string UrlEncode(object value) { string strValue = value switch { bool b => b ? "1" : "0", _ => value.ToString() }; // 自定义 URL 编码,将空格替换为 '+' 而不是 '%20' return WebUtility.UrlEncode(strValue.Trim()) .Replace("%20", "+") .Replace("%21", "!") .Replace("%27", "'") .Replace("%28", "(") .Replace("%29", ")") .Replace("%7E", "~"); } ```
C#UnitTest GPT FAQs
More custom GPTs by @noob92533838 on the GPT Store
MermaidDiagrams
将用户描述转化为Mermaid图表代码
90+
C#Naming
基于用户需求提供符合C#命名规范的建议,助力提升代码的可读性和维护性。
40+
WBS(Work Breakdown Structure)
专注于用户需求分析与项目管理,擅长将复杂需求转化为具体的开发子任务,并提供优先级和依赖关系分析。
30+
C#Refactoring
C#代码重构专家AI助手,专注于C#编程与代码重构的开发者,负责审查和改进代码,以增强其可读性、可测试性、可扩展性和可维护性。
10+
StructuredPromptOptimize
基于用户输入的结构化Prompt分析并重构Prompt,以更准确地表达用户意图
8+
DBAAssistant
将用户需求转化为SQL Server或MySQL的SQL语句和数据库设计需求列表的AI助手
6+
DocToCSharpCode
根据用户输入的文档内容转换C#类定义
6+
JavaScriptRefactoring
专注于Javascript编程与代码重构,精通jQuery、knockout、vuejs等开源库和Typescript。旨在通过审查和改进代码来增强其可读性、可测试性、可扩展性和可维护性。
5+
PromptEngineer
专门将常规Prompt转化为遵循[CRISPE提示框架]的高效Prompt,并进一步优化为结构化Prompt。旨在提高输出的回复质量和达到预期目标。
4+

RespJsonToMarkdown
将Json格式的响应数据结构体以Markdown呈现
3+
BOREPrompt工程师
将用户的描述转换为B.O.R.E提示框架的Prompt
3+

FullStackEngineer
作为负责设计、开发和维护网络应用程序的前端和后端的全栈工程师AI助手,具备广泛的技术和编程语言知识。
3+

JenkinsGroovyRefactoring
专注于Groovy编程和代码重构的AI助手,旨在Jenkins环境下审查与改进Groovy代码。目标是增强代码的可读性、可测试性、可扩展性和可维护性,同时确保优化后的代码在Jenkins中能够正确执行。
3+
TestEngineer
解读功能需求和制定测试用例
2+

SQLToC#Code
SQL语句转换为C#代码
2+

CSharpDDD
基于DDD为客户需求生成高质量的代码,并提供具有清晰领域模型的方案
2+

C#CodeRefactoring
C# 代码重构专家
2+

BuildAdminHtml
根据用户需求构建后台页面
2+
ReqJsonToMarkdown
将Json格式的请求数据结构以Markdown表格方式展示
2+
JsonToCSharpCode
将Json数据中的结构转换为C#代码
1+

PowerShellRefactoring
专注于PowerShell编程与代码重构的AI助手,负责审查和改进PowerShell脚本。通过重构提升脚本的可读性、可测试性、可扩展性和可维护性
1+
Best Alternative GPTs to C#UnitTest on GPTs Store
C# (Csharp)
Your personal highly sophisticated C# (Csharp) language copilot, with a focus on efficient, scalable and high-quality production C# code.
50K+
C Programming Language Assistant
🆕 updated May, 6, 2025 ................... ............................................. ....................................... ... C programming expert with deep knowledge of the language and its best practices
50K+
C++
Get help from an expert in C++ coding, trained on hundreds of the most difficult C++ challenges. Start with a quest! ⬇🧑💻 (V1.7)
25K+
Expert in C/C++ Coding
C++ expert on modern practices and guidelines.
25K+
DotNet Senior Developer (C#)
An DotNet (.net) C# bot deeply skilled in .NET, ASP.NET, Entity Framework, LINQ, WPF, and WCF. It helps you to analyse code to identify issues or writes test for your code. Upload your code for review, refactoring, test creation, explanation, commenting, or documentation writing.
25K+
C# Unit Test Creator
Generates unit tests for C# classes using xUnit and NSubstitute.
100+
Unit Tester
Writes unit test for C# and .NET
100+
C# Unit Test Helper
Expert in C# unit testing with xUnit, focusing on best practices.
80+
C# .NET Unit Test Specialist
Writes detailed C# unit tests in xUnit format.
70+
dotnet C# unit test creator
Create an dotnet unit test with xUnit / AutoFixture/ Moq/ FluentAssertions
50+
C# Unit Test Generator
Generates unit tests in C# and provides testing best practices.
40+
CppTest Wizard
Provides expert-level C++ unit test guidance and generation.
40+
C# UnitTests
Generate C# UnitTests with XUnit, FluentAssertions and FakeItEasy
30+
Unit Test Helper
Expert in writing, fixing, and optimizing unit tests for Java, JS, TS, Go, Rust, C#.
20+
🔧 C# Unit Test Engineer Role-play
Become a meticulous software engineer focusing on writing unit tests in C#. 📊 Your goal is to ensure the reliability of a critical software system. 👨💻🌟💻
10+
CMock Co-Pilot
Expert in increasing unit-test coverage for C code using CMock.
10+
Unit Test Boss
I write unit tests for uploaded Dynamics 365 C# code files.
10+
Unit Test C# Code Generator
Asistente para generar código C# de pruebas unitarias
6+
C# Unit Test
Create C# unit tests for your classes using xunit and NSubstitute
2+
🔧 C# Unit Test Engineer Role-play
Become a meticulous software engineer focusing on writing unit tests in C#. 📊 💻 Your goal is to ensure the reliability of a critical software system. 👨💻 Experience the intricate art of crafting comprehensive unit tests, handling edge cases and ensuring graceful software failure! 🌟