Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

tests: add the first tests for ViewLocator

Đang mở Phù hợp với người mới
#341 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
88/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
csharp
Lĩnh vực
desktop, testing-qa

Hướng nghiên cứu

Thêm một tệp kiểm thử trong tests/LageBuch.Acceptance.Tests/ cho src/LageBuch.App.Shared/ViewLocator.cs. Bắt đầu bằng cách đọc ViewLocator.cs và NumericInputTests.cs, sau đó chạy make test PROJECT=tests/LageBuch.Acceptance.Tests FILTER=Name~ViewLocator. Bao gồm trường hợp fallback null, fallback khi không tìm thấy view và các assertion Match; các bài kiểm thử đã lọc sẽ chạy thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

good first issue tests

src/LageBuch.App.Shared/ViewLocator.cs maps a view model to its view by string
convention: it replaces ViewModel with View in the type name and resolves
that type. Convention-based resolution breaks quietly when a file is renamed,
and there is no test file for it anywhere — the only mention in tests/ is a
passing comment in ForcesTabRenderTests.cs.

What to do

Add a new test file in tests/LageBuch.Acceptance.Tests/ (the only test project
that references LageBuch.App.Shared). Three cheap assertions cover the whole
class:

  1. Build(null) returns a TextBlock whose text is the em-dash placeholder.
  2. Build(x) for an ObservableObject subclass with no matching view returns a
    TextBlock starting with Nicht gefunden:.
  3. Match is true for a CommunityToolkit.Mvvm.ComponentModel.ObservableObject
    and false for a plain object.

The two fallback paths construct a TextBlock only, so a plain [Fact] is
enough and you do not need the Avalonia dispatcher. If you want to also assert
that a real view model resolves to its view, use [AvaloniaFact] and copy the
setup from NumericInputTests.cs in the same project.

Note this project is on xunit.v3 while the other test projects are on v2.

Verify
make test PROJECT=tests/LageBuch.Acceptance.Tests FILTER=Name~ViewLocator

Difficulty: easy.


New here?

Comment to claim this issue and it is yours. If no pull request appears within
seven days it goes back in the pool, no hard feelings.

Before you open the PR, please skim CONTRIBUTING.md:
commits need DCO sign-off (git commit -s) and a Conventional Commit subject.
Changes under src/ additionally need an entry under ## [Unreleased] in
CHANGELOG.md — CI fails the PR otherwise.

Questions are welcome right here or in
Discussions.

Ngôn ngữ chính
C#
Star
1
Fork
3
Merge trung bình
4 giờ 49 phút
Pull request đã merge (30 ngày)
177

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của CodeForFire/lagebuch

Tất cả issue của CodeForFire/lagebuch

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.